ACM--特训1--A - A Math Problem HDU - 6182

You are given a positive integer n, please count how many positive integers k satisfy  kknkk≤n
InputThere are no more than 50 test cases. 

Each case only contains a positivse integer n in a line. 

1n10181≤n≤1018 
OutputFor each test case, output an integer indicates the number of positive integers k satisfy  kknkk≤n in a line.Sample Input
1
4
Sample Output
1
2


#include <iostream>

using namespace std;
typedef long long ll;

//a ^ a
__int64 POW(ll a)
{
    __int64 result = 1;
    ll base = a;
    ll tmp = a;
    while(tmp > 0)
    {
        if((tmp & 1) == 1)
            result = result * base;
        base = base * base;
        tmp >>= 1;
    }
    return result;
}

int main()
{
    ios::sync_with_stdio(false);
    __int64 n;
    while(cin >> n)
    {
        for(int i = 15 ; i >= 0 ; i--)
        {
            if(POW(i) <= n)
            {
                cout << i << endl;
                break;
            }
        }
    }
    return 0;
}

猜你喜欢

转载自blog.csdn.net/xiaorui98/article/details/81050125
今日推荐