main
黄海 2 years ago
parent 33da555a91
commit 7c6bee650b

@ -1,38 +1,40 @@
#include <bits/stdc++.h> #include <bits/stdc++.h>
using namespace std; using namespace std;
#define ll long long #define LL long long
const int N = 100 + 100; const int N = 100 + 100;
ll mu[N * 100], primes[N * 100], st[N * 100];
int cnt;
void get_mobius() { LL mu[N], sum[N];
int primes[N], cnt;
bool st[N];
void get_mobius(LL n) {
mu[1] = 1; mu[1] = 1;
for (int i = 2; i < N; i++) { for (LL i = 2; i <= n; i++) {
if (!st[i]) { if (!st[i]) {
primes[cnt++] = i; primes[cnt++] = i;
mu[i] = -1; mu[i] = -1;
} }
for (int j = 0; j < cnt; j++) { for (LL j = 0; primes[j] <= n / i; j++) {
ll t = primes[j] * i; LL t = primes[j] * i;
if (primes[j] > N / i) { st[t] = true;
break;
}
st[t] = 1;
if (i % primes[j] == 0) { if (i % primes[j] == 0) {
mu[t] = 0; mu[t] = 0;
break; break;
} }
mu[t] = -mu[i]; mu[t] = mu[i] * -1;
} }
} }
// 维护u(x)前缀和
for (LL i = 1; i <= n; i++) sum[i] = sum[i - 1] + mu[i];
} }
int main() { int main() {
get_mobius(); get_mobius(N - 1);
ll tmp;
LL tmp;
while (cin >> tmp) { while (cin >> tmp) {
ll sum = 1; LL sum = 1;
for (ll i = 2; i <= 64; i++) { for (LL i = 2; i <= 64; i++) {
sum -= mu[i] * (ll)(pow(tmp * 1.0, 1.0 / i) - 1); sum -= mu[i] * (LL)(pow(tmp * 1.0, 1.0 / i) - 1);
} }
cout << sum << endl; cout << sum << endl;
} }

Loading…
Cancel
Save