HDU 6182

题意

输入一个n ( 0 <= n <= 1018 ) 求有多少个k 使得 kkn

思路

这个题蜜汁爆llu
用计算器试一下就知道当k = 16时, kk=1616 已经超过 1018
所以最多是15 故用最朴素的循环求kk 就行

AC代码

#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cstring>

using namespace std;
typedef unsigned long long ll;
ll n, i, cnt;

bool judge( ll a ){
    ll ans = 1;
    for( ll i = 1; i <= a; i++ ){
        ans *= a;
        if( ans > n ) return 0;
    }
    return ans <= n;
}

int main()
{
    while( ~scanf("%llu",&n) ){
        cnt = 0;
        for( i = 1; ; i++ )
            if( judge(i) )
                cnt++;
            else break;
        printf("%llu
",cnt);
    }
    return 0;
}
原文地址:https://www.cnblogs.com/JinxiSui/p/9740560.html