根据指数的质数分解进行容斥 比如 k = a^3 且 k = b ^ 5,那么 k = c ^ 15
所以 a 的可选个数 加 b的可选个数减去c的可减个数就是总的个数了因为 a^3和b^5有重复的
#include<cstdio>
#include<algorithm>
#include<iostream>
#include<cstring>
#include<string>
#include<cmath>
#define LL long long
using namespace std;
int X[50] = {2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61};
LL ans = 0, n;
void dfs(int pre, int index, int am)
{
if(pre >= 62) return ;
if(am != 0)
{
LL tmp = pow(n * 1.0, 1.0 / pre) + 1e-6;
tmp--;
if(tmp > 0)
{
if(am & 1) ans += tmp;
else ans -= tmp;
}
}
for(int i = index; X[i] < 61; i++)
dfs(pre * X[i], i + 1, am + 1);
}
int main()
{
while(scanf("%I64d", &n)!=EOF)
{
ans = 1;
dfs(1, 0, 0);
printf("%I64d\n", ans);
}
return 0;
}