hdu6033 Add More Zero

来源:互联网 发布:浪潮税控开票软件 编辑:程序博客网 时间:2024/05/18 12:34

题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=6033
题意:让你求2^m-1次方里面是几位数,即对2^m-1取以10为底的对数
解析:由于不减一也不可能出现增加位数的情况,所以可以直接对2^m次方求对数,换底公式得ans = m*log(2)/log(10)

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