本文主要是介绍Codeforces 434 Div. 2 A,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
A. k-rounding
time limit per test1 second
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
题意:…..
#include <iostream>#include <fstream>#include <cstdio>#include <cstring>#include <queue>#include <stack>#include <vector>#include <map>#include <set>#include <cmath>#include <algorithm>#include <functional>#define inf 0x7fffffffusing namespace std;typedef long long ll;const int MAXN=1e5+10;const int MAX=1e5+10;const double eps=1e-6;int main(){#ifdef ONLINE_JUDGE#elsefreopen("in.txt","r",stdin);//freopen("out.txt","w",stdout);#endifll num,k;cin>>num>>k;ll maxx=num;for(int i=1;i<=k;i++) maxx=maxx*10;int flag=0;if((num%10)==9||(num%10)==3||(num%10)==7||(num%10)==1||num==1){cout<<maxx<<endl;return 0;}for(ll i=1;;i++){if(((num%10)*i)%10!=0)continue;ll temp=num*i;ll t=temp;if(temp>maxx)break;int cnt=0;while(temp%10==0){cnt++;temp=temp/10;}if(cnt>=k){flag=1;cout<<t<<endl;break;}}if(!flag) cout<<maxx<<endl; return 0; }
#include <iostream>#include <fstream>#include <cstdio>#include <cstring>#include <queue>#include <stack>#include <vector>#include <map>#include <set>#include <cmath>#include <algorithm>#include <functional>#define inf 0x7fffffffusing namespace std;typedef long long ll;const int MAXN=1e5+10;const int MAX=1e5+10;const double eps=1e-6;ll gcd(ll a,ll b){return (!b)?a:gcd(b,a%b);}int main(){#ifdef ONLINE_JUDGE#elsefreopen("in.txt","r",stdin);//freopen("out.txt","w",stdout);#endifll num,k;ll temp=1;cin>>num>>k;for(int i=1;i<=k;i++) temp*=10;cout<<num/gcd(num,temp)*temp<<endl;return 0; }
#include <iostream>#include <fstream>#include <cstdio>#include <cstring>#include <queue>#include <stack>#include <vector>#include <map>#include <set>#include <cmath>#include <algorithm>#include <functional>#define inf 0x7fffffffusing namespace std;typedef long long ll;const int MAXN=1e5+10;const int MAX=1e5+10;const double eps=1e-6;int main(){#ifdef ONLINE_JUDGE#elsefreopen("in.txt","r",stdin);//freopen("out.txt","w",stdout);#endifll num,k;cin>>num>>k;ll temp=1;for(int i=1;i<=k;i++){if(num%2==0)num=num/2;if(num%5==0)num=num/5;temp=temp*10;}cout<<num*temp<<endl;return 0; }
这篇关于Codeforces 434 Div. 2 A的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!