2017 Multi-University Training Contest

来源:互联网 发布:单机服装销售软件 编辑:程序博客网 时间:2024/05/30 23:03

http://acm.hdu.edu.cn/showproblem.php?pid=6033


题意:

跟你一个m,求一个k的最小值,使得10k>2m - 1

思路:

其实就是求n * log102,非常简单。
log102可以用换底公式(log(2) / (log(10)替换,最后答案向下取整。

代码:

#include<bits/stdc++.h>using namespace std;int main(){    int n;    int cas = 1;    while(~scanf("%d",&n)){        double ans = n * (log(2)) / (log(10));        printf("Case #%d: %d\n",cas++,(int)ans);    }}
原创粉丝点击