题目链接

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.

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已知的情况下求k,其关系式为:

10k=2m-1

看到这个式子首先想到用对数公式来化简,但是因为等式右面的式子是2^m-1这样的话是没有办法化简得,有没有办法解决呢?

我们注意到一点就是不管2的几次幂,其最后的一位数字都是在2,4,6,8这几个数字中循环,所以尽管将其结果后面减去的哪个1不考虑也不会影响其十位数的大小,这样的话转换成10的幂次也不会改变。

关系式就变成10k=2m两边同时取以10为底的对数然后将k表示出来就是:k=m*log10(2);

#include<iostream>
#include <cmath>
#include <stdio.h>
using namespace std;
int main()
{
int m,Case=0;
while(~scanf("%d",&m))
{
Case++;
int k=(int)(m*log10(2));
printf("Case #%d: %d\n", Case, k);
}
return 0;
}

2017ACM暑期多校联合训练 - Team 1 1001 HDU 6033 Add More Zero (数学)的更多相关文章

  1. 2017ACM暑期多校联合训练 - Team 7 1009 HDU 6128 Inverse of sum (数学计算)

    题目链接 Problem Description There are n nonnegative integers a1-n which are less than p. HazelFan wants ...

  2. 2017ACM暑期多校联合训练 - Team 6 1001 HDU 6096 String (字符串处理 字典树)

    题目链接 Problem Description Bob has a dictionary with N words in it. Now there is a list of words in wh ...

  3. 2017ACM暑期多校联合训练 - Team 5 1001 HDU 6085 Rikka with Candies (模拟)

    题目链接 Problem Description As we know, Rikka is poor at math. Yuta is worrying about this situation, s ...

  4. 2017ACM暑期多校联合训练 - Team 2 1011 HDU 6055 Regular polygon (数学规律)

    题目链接 **Problem Description On a two-dimensional plane, give you n integer points. Your task is to fi ...

  5. 2017ACM暑期多校联合训练 - Team 2 1001 HDU 6045 Is Derek lying? (模拟)

    题目链接 Problem Description Derek and Alfia are good friends.Derek is Chinese,and Alfia is Austrian.Thi ...

  6. 2017ACM暑期多校联合训练 - Team 4 1004 HDU 6070 Dirt Ratio (线段树)

    题目链接 Problem Description In ACM/ICPC contest, the ''Dirt Ratio'' of a team is calculated in the foll ...

  7. 2017ACM暑期多校联合训练 - Team 9 1005 HDU 6165 FFF at Valentine (dfs)

    题目链接 Problem Description At Valentine's eve, Shylock and Lucar were enjoying their time as any other ...

  8. 2017ACM暑期多校联合训练 - Team 9 1010 HDU 6170 Two strings (dp)

    题目链接 Problem Description Giving two strings and you should judge if they are matched. The first stri ...

  9. 2017ACM暑期多校联合训练 - Team 8 1006 HDU 6138 Fleet of the Eternal Throne (字符串处理 AC自动机)

    题目链接 Problem Description The Eternal Fleet was built many centuries ago before the time of Valkorion ...

随机推荐

  1. DataSet和List 泛型之间互相转换 (转载)

    //DataSet与泛型集合间的互相转换 //利用反射机制将DataTable的字段与自定义类型的公开属性互相赋值. //注意:从DataSet到IList<T>的转换,自定义类型的公开属 ...

  2. 3dContactPointAnnotationTool开发日志(二四)

      添加了清空2d接触点的按钮,将输出的2d接触点的单位变成了像素,原点在图像的左下角.   对于obj文件的适配更加多样化了.

  3. js移动端滑块验证解锁组件

    本文修改自PC端的js滑块验证组件,PC端使用的是onmousedown,onmouseup,nomousemove.原文找不到了,也是博客园文章,在此感谢广大网友的生产力吧. 说下对插件和组件的理解 ...

  4. 【Linux】- 文件基本属性

    Linux系统是一种典型的多用户系统,不同的用户处于不同的地位,拥有不同的权限.为了保护系统的安全性,Linux系统对不同的用户访问同一文件(包括目录文件)的权限做了不同的规定. 在Linux中我们可 ...

  5. 硬盘引导扇区、多分区图、不通硬盘的LINUX逻辑分区数量

    主要启动记录区(Master Boot Record,MBR):可以安装开机管理程序的地方,有446byte 分割表(Paritition table):记录整块硬盘分割的状态,有64bytes 下面 ...

  6. 细说匿名内部类引用方法局部变量时为什么需要声明为final

    一.前言 在研究公司某个项目的源码,看到前人使用了挺多内部类,内部类平时我用的比较多的是匿名内部类,平时用的多的是匿名内部类,其他形式的用的比较少,然后我就有个疑惑:到底内部类是基于什么样的考虑,才让 ...

  7. vmware 虚拟机下安装centOS7.0

    当时安装的是 CentOS-7.0-1406-x86_64-DVD.iso 这个版本的镜像,提示: 您已经配置此虚拟机使用64位客户操作系统.但是64位操作系统不可用.此主机具有虚拟化支持能力的,可是 ...

  8. RT-thread-2.0.1移植(基于STM32F4xx)

    1.将下载的rt-thread-2.0.1解压后,得到如下图所示的文件列表. 在bsp目录下可以找到stm32f40x文件夹,这文件夹里面包括了库函数,其他芯片平台的文件夹统统删掉.在libcpu下, ...

  9. 【bzoj2435】[NOI2011]道路修建 树形dp

    题目描述 在 W 星球上有 n 个国家.为了各自国家的经济发展,他们决定在各个国家之间建设双向道路使得国家之间连通.但是每个国家的国王都很吝啬,他们只愿意修建恰好 n – 1条双向道路. 每条道路的修 ...

  10. 题解【luogu4145 上帝造题的七分钟2(花神游历各国)】

    题目大意: 一个序列,支持区间开方与求和操作. 算法:线段树实现开方修改与区间求和 分析: 显然,这道题的求和操作可以用线段树来维护 但是如何来实现区间开方呢 大家有没有这样的经历:玩计算器的时候,把 ...