鸿 网 互 联 www.68idc.cn

当前位置 : 服务器租用 > 编程语言开发 > c++ > >

HDU_6033_Add More Zero

来源:互联网 作者:佚名 时间:2018-02-27 09:55
Add More Zero Time Limit: 2000/1000 MS (Java/Others)Memory Limit: 131072/131072 K (Java/Others) Total Submission(s): 2042Accepted Submission(s): 1278 Problem Description There is a youngster known for amateur propositions concerning severa

Add More Zero

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 131072/131072 K (Java/Others)
Total Submission(s): 2042    Accepted Submission(s): 1278


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 and (2m1) (inclusive).

As a young man born with ten fingers, he loves the powers of 10 so much, which results in his eccentricity that he always ranges integers he would like to use from 1to 10k (inclusive).

For the sake of processing, all integers he would use possibly in this interesting problem ought to be as computable as this supercomputer could.

Given the positive integer m, your task is to determine maximum possible integer k that is suitable for the specific supercomputer.
 

 

Input The input contains multiple test cases. Each test case in one line contains only one positive integer m, satisfying 1m105.  

 

Output For each test case, output "Case #xy" in one line (without quotes), where x indicates the case number starting from 1 and y denotes the answer of corresponding case.  

 

Sample Input 1 64  

 

Sample Output Case #1: 0 Case #2: 19  

 

Source 2017 Multi-University Training Contest - Team 1  
  • 对于2^m-1>=10^k
  • 解得k<=lb(2^m-1)/lb(10)
  • 即k<=m/lb(10)

 

 

 1 #include <iostream>
 2 #include <string>
 3 #include <cstdio>
 4 #include <cstring>
 5 #include <algorithm>
 6 #include <climits>
 7 #include <cmath>
 8 #include <vector>
 9 #include <queue>
10 #include <stack>
11 #include <set>
12 #include <map>
13 using namespace std;
14 typedef long long           LL ;
15 typedef unsigned long long ULL ;
16 const int    maxn = 1e5 + 10   ;
17 const int    inf  = 0x3f3f3f3f ;
18 const int    npos = -1         ;
19 const int    mod  = 1e9 + 7    ;
20 const int    mxx  = 100 + 5    ;
21 const double eps  = 1e-6       ;
22 const double PI   = acos(-1.0) ;
23 
24 int main(){
25     // freopen("in.txt","r",stdin);
26     // freopen("out.txt","w",stdout);
27     int T=0;
28     double m;
29     while(~scanf("%lf",&m)){
30         printf("Case #%d: %d\n",++T,(int)(m/log2((double)10)));
31     }
32     return 0;
33 }

 

 

 

网友评论
<