首页 > 其他 > 详细

Tom and Zeros

时间:2019-04-21 20:34:06      阅读:235      评论:0      收藏:0      [点我收藏+]

Description

 

Tom is the most handsome CCPC contestant in HIT.Tom likes Zero. For a given positive integer n, he wants to know the minimum non_negativeinteger which is divisible by n and ends with k or more zeros. For example, if n is 75 and k is 4, theresult is 75*400 = 30000.

 

Input

 

The first line contains an integer T(0<=T<=100) which means T test cases.Each test case contains two integers n and k.1<=n<=1e9 , 0<=k<=8.

 

Output

 

For each test case, print one line with the answer

 

Sample Input 1 

2
75 4
10000 1

Sample Output 1

30000
10

该题就是求最小公倍数;
#include<iostream>
using namespace std;
long long gcd(long a,long b)
{
long long c;
while(b>0)
{
c=a%b;
a=b;
b=c;
}
return a;
}
long long cheng(long long k)
{
long long sum=1;
while(k--)
{
sum*=10;
}
return sum;
}
int main()
{
long long t,n,k,m;
cin>>t;
while(t--)
{
cin>>n>>k;
k=cheng(k);
m=(n*k)/gcd(n,k);
cout<<m<<endl;
}
return 0;
}

 

Tom and Zeros

原文:https://www.cnblogs.com/ylrwj/p/10746640.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!