题目来源:http://codeforces.com/problemset/problem/858/A
For a given positive integer n denote its k-rounding as the minimum positive integer x, such that x ends with k or more zeros in base 10 and is divisible by n.
For example, 4-rounding of 375 is 375·80 = 30000. 30000 is the minimum integer such that it ends with 4 or more zeros and is divisible by 375.
Write a program that will perform the k-rounding of n.
Input
The only line contains two integers n and k (1 ≤ n ≤ 109, 0 ≤ k ≤ 8).
Output
Print the k-rounding of n.
Examples
input
375 4
output
30000
input
10000 1
output
10000
input
38101 0
output
38101
input
123456789 8
output
12345678900000000
运用gcd函数(求公因数)可以将个这道题写出来,但要注意数据的范围(int 不够要 l l):
#include<stdio.h>
#include<string.h>
#include<math.h>
#include<string>
#include<iostream>
#include<algorithm>
using namespace std;
#define ll long long
//#define da 10000000
//#define xiao -10000000
#define clean(a,b) memset(a,b,sizeof(a))
ll gcd(int n,int z) //gcd函数求最大公因数
{
return z?gcd(z,n%z):n;
}
int main()
{
ll n,k;
scanf("%d%d",&n,&k);
int i,j,z=1,can=1;
ll w=1;
for(i=0;i<k;++i)
z=z*10; //末尾0的个数
int da=n>z?n:z; //n和z(10^k)的公因数
int xiao=n<z?n:z;
ll yin=gcd(xiao,da); //求最大公因数
printf("%lld\n",(n*z)/yin); //(n*z ÷最大公因数)等于最小公倍数
}
求出最大公倍数就行了;