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.

47 lines
1.1 KiB

2 years ago
#include <bits/stdc++.h>
using namespace std;
2 years ago
#define int long long
#define endl "\n"
const int N = 110;
2 years ago
2 years ago
/*
mu-mu[i]
15MS
*/
2 years ago
// 筛法求莫比乌斯函数
2 years ago
int mu[N], primes[N], cnt;
2 years ago
bool st[N];
2 years ago
void get_mobius(int n) {
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; primes[j] <= n / i; j++) {
int t = primes[j] * i;
2 years ago
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];
2 years ago
}
}
}
2 years ago
2 years ago
signed main() {
2 years ago
// 筛法求莫比乌斯函数
2 years ago
get_mobius(N - 1);
2 years ago
int T;
2 years ago
while (cin >> T) {
2 years ago
int s = 1;
for (int i = 2; i <= 64; i++) s -= mu[i] * (int)(pow(T * 1.0, 1.0 / i) - 1);
2 years ago
cout << s << endl;
2 years ago
}
}