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.

43 lines
1010 B

2 years ago
#include <bits/stdc++.h>
using namespace std;
2 years ago
#define LL long long
2 years ago
const int N = 100 + 100;
2 years ago
2 years ago
// 筛法求莫比乌斯函数
2 years ago
LL mu[N], sum[N];
int primes[N], cnt;
bool st[N];
void get_mobius(LL n) {
2 years ago
mu[1] = 1;
2 years ago
for (LL i = 2; i <= n; i++) {
2 years ago
if (!st[i]) {
primes[cnt++] = i;
2 years ago
mu[i] = -1;
}
2 years ago
for (LL j = 0; primes[j] <= n / i; j++) {
LL t = primes[j] * i;
st[t] = true;
2 years ago
if (i % primes[j] == 0) {
mu[t] = 0;
2 years ago
break;
}
2 years ago
mu[t] = mu[i] * -1;
2 years ago
}
}
2 years ago
// 维护u(x)前缀和
2 years ago
// 这玩意有啥用?
2 years ago
for (LL i = 1; i <= n; i++) sum[i] = sum[i - 1] + mu[i];
2 years ago
}
2 years ago
2 years ago
int main() {
2 years ago
// 筛法求莫比乌斯函数
2 years ago
get_mobius(N - 1);
2 years ago
LL T;
while (cin >> T) {
2 years ago
LL s = 1;
2 years ago
for (LL i = 2; i <= 64; i++) s -= mu[i] * (LL)(pow(T * 1.0, 1.0 / i) - 1);
2 years ago
cout << s << endl;
2 years ago
}
return 0;
}