Add More Zero
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 131072/131072 K (Java/Others)Total Submission(s): 0 Accepted Submission(s): 0
Problem Description
There is a youngster known for amateur propositions concerning several mathematical hard problems.
Nowadays, he is preparing a thought-provoking problem on a specific type of supercomputer which has ability to support calculations of integers between 0 denotes the answer of corresponding case.
Nowadays, he is preparing a thought-provoking problem on a specific type of supercomputer which has ability to support calculations of integers between 0 denotes the answer of corresponding case.
Sample Input
1 64
Sample Output
Case #1: 0 Case #2: 19
思路:
题目是求[0,2^m-1]上的十进制数最大有多少位,即10^k中k的最大值。
显然k=log10(2^m-1),要是2^m就好了,我们算的是位数,如果+1影响到它的位数,说明2^m-1末位是9,显然不可能,则k=log10(2^m)=m*log10(2)。
ac代码:
#include<stdio.h>
#include<math.h>
int m;
int main()
{
int ans;
int cas=0;
while(~scanf("%d",&m))
{
ans= log10(2)*m;
printf("Case #%d: %d\n",++cas,ans);
}
return 0;
}
计算整数位数
本文介绍了一种计算[0,2^m-1]区间内整数最大位数的方法,并给出了具体的实现代码。通过计算log10(2^m),可以得出在该区间内整数的最大位数。
701

被折叠的 条评论
为什么被折叠?



