HDU_6033_Add More Zero

2018-06-17 21:46:35来源:未知 阅读 ()

新老客户大回馈,云服务器低至5折

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 }

 

 

 

标签:

版权申明:本站文章部分自网络,如有侵权,请联系:west999com@outlook.com
特别注意:本站所有转载文章言论不代表本站观点,本站所提供的摄影照片,插画,设计作品,如需使用,请与原作者联系,版权归原作者所有

上一篇:【luogu 1939】【模板】矩阵加速(数列)

下一篇:【luogu 2863】[USACO06JAN]牛的舞会The Cow Prom