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.

40 lines
911 B

2 years ago
#include <bits/stdc++.h>
using namespace std;
#define ll long long
2 years ago
const int N = 100 + 100;
2 years ago
ll mu[N * 100], primes[N * 100], st[N * 100];
int cnt;
2 years ago
void get_mobius() {
2 years ago
mu[1] = 1;
2 years ago
for (int i = 2; i < N; i++) {
2 years ago
if (!st[i]) {
primes[cnt++] = i;
2 years ago
mu[i] = -1;
}
2 years ago
for (int j = 0; j < cnt; j++) {
ll t = primes[j] * i;
if (primes[j] > N / i) {
2 years ago
break;
}
2 years ago
st[t] = 1;
if (i % primes[j] == 0) {
mu[t] = 0;
2 years ago
break;
}
2 years ago
mu[t] = -mu[i];
2 years ago
}
}
}
int main() {
2 years ago
get_mobius();
2 years ago
ll tmp;
while (cin >> tmp) {
ll sum = 1;
for (ll i = 2; i <= 64; i++) {
sum -= mu[i] * (ll)(pow(tmp * 1.0, 1.0 / i) - 1);
}
cout << sum << endl;
}
return 0;
}