17 多校1 Add More Zero 水题
Posted Annetree的博客
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了17 多校1 Add More Zero 水题相关的知识,希望对你有一定的参考价值。
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 1 to 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.
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 1 to 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 1≤m≤105.
Output
For each test case, output "Case #x: y" 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
题意:给你m,得到一个数(2^m-1),问这个数最多有10的几次
题解:简单粗暴地记录log10(2),再拿m去除以它,经验算得符合结果
1 #include<iostream> 2 #include<cstdio> 3 #include<queue> 4 #include<vector> 5 #include<cstring> 6 #include<string> 7 #include<algorithm> 8 #include<map> 9 #include<cmath> 10 #include<math.h> 11 using namespace std; 12 13 const double p=log(10.0)/log(2.0); 14 15 int main() 16 { 17 int t=1,m; 18 while(~scanf("%d",&m)) 19 { 20 printf("Case #%d: %d\n",t++,int(m/p)); 21 } 22 return 0; 23 }
以上是关于17 多校1 Add More Zero 水题的主要内容,如果未能解决你的问题,请参考以下文章
2017 多校训练题解1 [A.Add More Zero] 数学