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;
}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值