You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
|
|
|
#include <bits/stdc++.h>
|
|
|
|
|
using namespace std;
|
|
|
|
|
#define int long long
|
|
|
|
|
#define endl "\n"
|
|
|
|
|
const int N = 110;
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
我们可以利用莫比乌斯系数进行简化计算,在上一个版本中,我们是按照奇加偶减的原则来进行的,
|
|
|
|
|
同样这个计算的过程可以通过莫比乌斯中的mu函数来直接算出,每次相乘的系数是-mu[i]。
|
|
|
|
|
|
|
|
|
|
执行时间:15MS
|
|
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
// 筛法求莫比乌斯函数
|
|
|
|
|
int mu[N], primes[N], cnt;
|
|
|
|
|
bool st[N];
|
|
|
|
|
void get_mobius(int n) {
|
|
|
|
|
mu[1] = 1;
|
|
|
|
|
for (int i = 2; i <= n; i++) {
|
|
|
|
|
if (!st[i]) {
|
|
|
|
|
primes[cnt++] = i;
|
|
|
|
|
mu[i] = -1;
|
|
|
|
|
}
|
|
|
|
|
for (int j = 0; primes[j] <= n / i; j++) {
|
|
|
|
|
int t = primes[j] * i;
|
|
|
|
|
st[t] = true;
|
|
|
|
|
if (i % primes[j] == 0) {
|
|
|
|
|
mu[t] = 0;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
mu[t] = -mu[i];
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
signed main() {
|
|
|
|
|
// 筛法求莫比乌斯函数
|
|
|
|
|
get_mobius(N - 1);
|
|
|
|
|
|
|
|
|
|
int T;
|
|
|
|
|
while (cin >> T) {
|
|
|
|
|
int s = 1;
|
|
|
|
|
|
|
|
|
|
for (int i = 2; i <= 64; i++) s -= mu[i] * (int)(pow(T * 1.0, 1.0 / i) - 1);
|
|
|
|
|
cout << s << endl;
|
|
|
|
|
}
|
|
|
|
|
}
|