HDU 6033 模拟小数学

传送门:http://acm.hdu.edu.cn/showproblem.php?pid=6033

题意:已知m,求使10k不超过2m-1的最大的k。

分析:

因为是10进制,其实就是求出2m-1的位数。

2m都是以2,4,6,8结尾,因此减1不影响2m-1的位数。10的k次方都是以0结尾

所以令10k=2m,则k=m * log102,下取整即可。直接用对数函数即可

#include <stdio.h>
#include <string.h>
#include <iostream>
#include <algorithm>
#include <queue>
#include <cmath>
using namespace std;
typedef long long LL;

int main(){
    int p = 1;
    int n;
    while(~scanf("%d", &n)) {
        double ans = n*log10(2);
        printf("Case #%d: %d\n",p++, (int)ans);
    }
    return 0;
}

 

posted @ 2017-07-26 17:46  Lawliet__zmz  阅读(171)  评论(0编辑  收藏  举报