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

 

转载于:https://www.cnblogs.com/ylrwj/p/10746640.html

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值