题目链接:点击打开题目
就是问2^m-1有多少位,再减一就是答案了。
求一个数有多少位对它求log,以10为底,求对数。
可以变成 mlog10(2),后面那个减一可以忽略。
代码如下:
#include<cmath>
#include<cstdio>
#include<algorithm>
using namespace std;
typedef long long LL;
int main()
{
int m;
int Case = 1;
while (~scanf ("%d",&m))
{
int ans = m * (log(2.0) / log(10.0));
printf ("Case #%d: %d\n",Case++,ans);
}
return 0;
}