博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
HDU_6033_Add More Zero
阅读量:4322 次
发布时间:2019-06-06

本文共 2158 字,大约阅读时间需要 7 分钟。

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
 
  • 对于2^m-1>=10^k
  • 解得k<=lb(2^m-1)/lb(10)
  • 即k<=m/lb(10)

 

 

1 #include 
2 #include
3 #include
4 #include
5 #include
6 #include
7 #include
8 #include
9 #include
10 #include
11 #include
12 #include
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 }

 

 

 

转载于:https://www.cnblogs.com/edward108/p/7668758.html

你可能感兴趣的文章
Qt之模拟时钟
查看>>
第一次接触安卓--记于2015.8.21
查看>>
(转)在分层架构下寻找java web漏洞
查看>>
mac下多线程实现处理
查看>>
C++ ifstream ofstream
查看>>
跟初学者学习IbatisNet第四篇
查看>>
seL4环境配置
查看>>
Git报错:insufficient permission for adding an object to repository database .git/objects
查看>>
ajax跨域,携带cookie
查看>>
BZOJ 1600: [Usaco2008 Oct]建造栅栏( dp )
查看>>
洛谷 CF937A Olympiad
查看>>
Codeforces Round #445 C. Petya and Catacombs【思维/题意】
查看>>
用MATLAB同时作多幅图
查看>>
python中map的排序以及取出map中取最大最小值
查看>>
ROR 第一章 从零到部署--第一个程序
查看>>
<form>标签
查看>>
vue去掉地址栏# 方法
查看>>
Lambda03 方法引用、类型判断、变量引用
查看>>
was集群下基于接口分布式架构和开发经验谈
查看>>
MySQL学习——MySQL数据库概述与基础
查看>>