Codeforces 434 Div. 2 A
来源:互联网 发布:达科塔约翰逊知乎 编辑:程序博客网 时间:2024/06/05 08:03
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 #else freopen("in.txt","r",stdin); //freopen("out.txt","w",stdout); #endif ll 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 #else freopen("in.txt","r",stdin); //freopen("out.txt","w",stdout); #endif ll 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 #else freopen("in.txt","r",stdin); //freopen("out.txt","w",stdout); #endif ll 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; }
阅读全文
0 0
- Codeforces 434 Div. 2 A
- CodeForces #140 (Div. 2)-A.
- CodeForces #176(Div.2)-A
- codeforces #320 div 2A
- Codeforces--447Div.2--A
- Codeforces #284 (Div.1 A~E & Div.2 A~E)
- Cards(Codeforces 701A)(Codeforces Round #364Div.2 A)
- Codeforces Round #131 (Div. 2) A B
- Codeforces Round #174 (Div. 2) Problem A
- Codeforces Round #173 (Div. 2) A.Bit++
- Codeforces Round #181 (Div. 2) A题
- Codeforces Round #184 (Div. 2) A题
- Codeforces Round #185 (Div. 2)--A,B
- Codeforces Round #172 (Div. 2) A题
- Codeforces Round #166 (Div. 2) A题
- Codeforces Round #132 (Div. 2) A题
- Codeforces Round #131 (Div. 2) A题
- Codeforces Round #133 (Div. 2) A题
- 介绍几个绕开JS验证的方法(服务器端验证是必要的)
- 文章标题
- 流表项莫名地被删除 无故消失的解决方法和参考 流表删除的三种方式 OFPFC_DELETE_STRICT OFPFC_DELETE
- 浏览器中F5和CTRL F5的行为区别
- javabean是什么和总结javabean的两种使用方式
- Codeforces 434 Div. 2 A
- 51nod 1444 破坏道路 最短路
- RMQ算法的学习(区间最值问题)NYOJ 119 士兵杀敌(三)
- Android开发过程中的一些小问题
- 树梅派 moudbus
- include指令和include动作的区别
- 同一Tomcat下session共享及用户验证方案
- 用qss自定义控件
- 51个你需要知道的大数据术语