You are given a positive integer n, please count how many positive integers k satisfy
kk≤nkk≤n.
InputThere are no more than 50 test cases.
Each case only contains a positivse integer n in a line.
1≤n≤10181≤n≤1018
OutputFor each test case, output an integer indicates the number of positive integers k satisfy kk≤nkk≤n in a line.Sample Input
1 4
Sample Output
1 2
这是本次模拟赛的签到题,是说给你个long long范围内的数,然后找出有多少个数的多少次方小于等于这个数,使用快速幂,也可以不用,提前打表可以发现这个到了16^16次方就到顶了,所以只需要打出15^15次方即可。
#include<bits/stdc++.h>
using namespace std;
typedef unsigned long long ULL;
const ULL maxn=1e18;
const int shuzu=20;
ULL ss[shuzu];
int pi;
ULL quickmod(ULL a,ULL b,ULL c)
{
ULL ans=1;
a=a%c;
while(b){
if(b&1){
ans=ans*a%c;
}
b>>=1;
a=a*a%c;
}
return ans;
}
void maketable()
{
for(pi=1;pi<=15;pi++){
ss[pi]=quickmod(pi,pi,maxn);
}
}
int main()
{
ULL n;
maketable();
while(cin>>n){
int i;
if(n>=437893890380859375){
printf("%d\n",15);
}else{
for(i=1;i<pi;i++){
if(ss[i]>n){
break;
}
}
printf("%d\n",i-1);
}
}
return 0;
}