设为首页 加入收藏

TOP

HDU_6033_Add More Zero
2017-10-16 18:18:59 】 浏览:992
Tags:HDU_6033_Add More Zero

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 (2m?1) (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
 
  • 对于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 }

 

 

 

】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
上一篇C++ 类 & 对象 下一篇文件输入输出(一):重定向

最新文章

热门文章

Hot 文章

Python

C 语言

C++基础

大数据基础

linux编程基础

C/C++面试题目