codeforces 858 A k-rounding(数学)
来源:互联网 发布:coc 女王升级数据 编辑:程序博客网 时间:2024/05/18 21:09
A. k-rounding
time limit per test
1 secondmemory limit per test
256 megabytesinput
standard inputoutput
standard outputFor 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 10and 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
计算出n*x= y* 1ek
结果一定包含k个0 ,一定可以取余n 那么答案最小值就是n*1ek/gcd(n,1ek);
从宏观角度 列出表达式 观察计算结果
#include <iostream>#include <stdio.h>#include <string.h>#include <stack>#include <queue>#include <map>#include <set>#include <vector>#include <math.h>#include <bitset>#include <algorithm>#include <climits>using namespace std;const int N = 1000000;typedef long long LL;LL d[20];vector<LL>p;int main(){ d[0]=1; for(int i=1; i<=18; i++) d[i]=d[i-1]*10; LL n, k; scanf("%I64d %I64d", &n, &k); printf("%I64d\n",n*d[k]/__gcd(n,d[k])); return 0;}
阅读全文
0 0
- codeforces 858 A k-rounding(数学)
- Codeforces 858A k-rounding
- Codeforces 858A. k-rounding 数论
- codeforces 861A k-rounding
- Codeforces 898A. Rounding
- Codeforces 898 A Rounding
- Codeforces Round #434 k-rounding
- CodeForces - 762A k-th divisor (数学
- cf434 div.2 A. k-rounding
- CodeForces 351A Jeff and Rounding
- Codeforces Round #451 (Div. 2) A. Rounding
- 【Codeforces-402B】-Weird Rounding(数学,思维)
- A. Rounding
- codeforces 351A A. Jeff and Rounding(智商题+枚举)
- codeforces 351A A. Jeff and Rounding(★)
- Codeforces Round #204 (Div. 1) A. Jeff and Rounding
- codeforces 351A Jeff and Rounding(区间枚举)
- 【CodeForces 351A】Jeff and Rounding(思维)
- Mac环境下Angular CLI配置
- uva 839 紫书例题及代码理解
- hadoop案例分析(二)
- oracle 表查询总结
- HDU
- codeforces 858 A k-rounding(数学)
- Eclipse下maven使用嵌入式(Embedded)Neo4j创建Hello World项目
- 给你10分钟时间,根据上排给出十个数,在其下排填出对应的十个数
- c语言 ---- Stack实现
- 什么是跨域?
- Android移动开发-通过手势实现翻页效果
- sevlet 给客户端下载一个文件
- Spring Boot基础
- java中构造方法和方法全面解析