Tom and Zeros

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;
}

 

posted @ 2019-04-21 20:08  蓉~  阅读(204)  评论(0编辑  收藏  举报