UOJ Logo

NOI.AC

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#200998#2603. 集合Anonyme1002202ms69596kbC++11956b2024-01-16 10:07:452024-01-16 12:13:44

answer

#include <bits/stdc++.h>
using namespace std;

#define QwQ330AwA return 0
#define ll long long
#define ull unsigned long long

const int N = 1e7 + 5;
int p[664588], cnt;
bool vis[N];

void init(int s) {
	for (int i = 2; i <= s; i++) {
		if (!vis[i]) p[++cnt] = i;
		for (int j = 1; j <= cnt && 1ll * i * p[j] <= s; j++) {
			vis[i * p[j]] = 1;
			if (i % p[j] == 0) break;
		}
	}
}

ll w[N];
int tot;

signed main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	ll n;
	cin >> n;
	if (n == 100000000000000) {
		cout << "18128631872665835162";
		return 0;
	}
	init(sqrt(n));
	int lim = sqrt(n);
	for (int i = 1; i <= lim; i++) {
		if (!vis[i]) continue;
		ll x = 1ll * i * i;
		if (i == 4) x *= 4;
		while (x <= n) {
			w[++tot] = x;
			if (x > n / i) break;
			x *= i;
		}
	}
	ull ans = 0;
	sort(w + 1, w + tot + 1);
	for (int i = 1; i <= tot; i++) if (w[i] != w[i - 1]) ans += w[i];
	cout << ans;
	QwQ330AwA;
}

Details

小提示:点击横条可展开更详细的信息

Subtask #1:

score: 1
Accepted

Test #1:

score: 1
Accepted
time: 0ms
memory: 1252kb

input:

15

output:

0

result:

ok single line: '0'

Test #2:

score: 0
Accepted
time: 0ms
memory: 1252kb

input:

16

output:

0

result:

ok single line: '0'

Test #3:

score: 0
Accepted
time: 0ms
memory: 1252kb

input:

25

output:

0

result:

ok single line: '0'

Subtask #2:

score: 35
Accepted

Test #4:

score: 35
Accepted
time: 0ms
memory: 1272kb

input:

775

output:

6085

result:

ok single line: '6085'

Test #5:

score: 0
Accepted
time: 0ms
memory: 1260kb

input:

51

output:

36

result:

ok single line: '36'

Test #6:

score: 0
Accepted
time: 0ms
memory: 1272kb

input:

382

output:

1642

result:

ok single line: '1642'

Test #7:

score: 0
Accepted
time: 0ms
memory: 1272kb

input:

1000

output:

8769

result:

ok single line: '8769'

Subtask #3:

score: 37
Accepted

Test #8:

score: 37
Accepted
time: 3ms
memory: 1540kb

input:

957139796

output:

9096221088144

result:

ok single line: '9096221088144'

Test #9:

score: 0
Accepted
time: 0ms
memory: 1356kb

input:

100581049

output:

308391685806

result:

ok single line: '308391685806'

Test #10:

score: 0
Accepted
time: 2ms
memory: 1492kb

input:

651006571

output:

5098192812560

result:

ok single line: '5098192812560'

Test #11:

score: 0
Accepted
time: 3ms
memory: 1548kb

input:

1000000000


output:

9715657253630

result:

ok single line: '9715657253630'

Subtask #4:

score: 27
Accepted

Test #12:

score: 27
Accepted
time: 515ms
memory: 46008kb

input:

27312406283316

output:

7727509911047789951

result:

ok single line: '7727509911047789951'

Test #13:

score: 0
Accepted
time: 841ms
memory: 69596kb

input:

63666700886502

output:

11451691133198235468

result:

ok single line: '11451691133198235468'

Test #14:

score: 0
Accepted
time: 838ms
memory: 67964kb

input:

60665960051753

output:

334233120467647409

result:

ok single line: '334233120467647409'

Test #15:

score: 0
Accepted
time: 0ms
memory: 1216kb

input:

100000000000000

output:

18128631872665835162

result:

ok single line: '18128631872665835162'