QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#291046#4136. Longge 的问题MoRanSky100 ✓1ms3864kbC++23531b2023-12-26 04:36:052023-12-26 04:36:06

Judging History

你现在查看的是最新测评结果

  • [2023-12-26 04:36:06]
  • 评测
  • 测评结果:100
  • 用时:1ms
  • 内存:3864kb
  • [2023-12-26 04:36:05]
  • 提交

answer

#include <cstdio>
#include <iostream>
using namespace std;
typedef long long LL;
LL n;
LL ans = 0;
int phi(LL x) {
	LL res = x;
	for (int i = 2; i <= x / i; i++) {
		if(x % i == 0) {
			res = res / i * (i - 1);
			while(x % i == 0) x /= i;
		}
	}
	if(x > 1) res = res / x * (x - 1);
	return res;
}
int main() {
	scanf("%lld", &n);
	for (int i = 1; i <= n / i; i++) {
		if(n % i == 0) {
			ans += (LL)i * phi(n / i);
			if(n / i != i) ans += (LL)n / i * phi(i);
		}
	}
	printf("%lld\n", ans);
	return 0;
}

详细

Test #1:

score: 10
Accepted
time: 0ms
memory: 3816kb

input:

10001

output:

39585

result:

ok single line: '39585'

Test #2:

score: 10
Accepted
time: 1ms
memory: 3624kb

input:

31243

output:

124261

result:

ok single line: '124261'

Test #3:

score: 10
Accepted
time: 0ms
memory: 3632kb

input:

12345

output:

74025

result:

ok single line: '74025'

Test #4:

score: 10
Accepted
time: 1ms
memory: 3628kb

input:

54321

output:

352425

result:

ok single line: '352425'

Test #5:

score: 10
Accepted
time: 1ms
memory: 3864kb

input:

1987612345

output:

7155404433

result:

ok single line: '7155404433'

Test #6:

score: 10
Accepted
time: 0ms
memory: 3612kb

input:

20321

output:

75465

result:

ok single line: '75465'

Test #7:

score: 10
Accepted
time: 0ms
memory: 3692kb

input:

1000009999

output:

2000019997

result:

ok single line: '2000019997'

Test #8:

score: 10
Accepted
time: 0ms
memory: 3632kb

input:

1000

output:

8500

result:

ok single line: '8500'

Test #9:

score: 10
Accepted
time: 1ms
memory: 3560kb

input:

987654321

output:

13284901413

result:

ok single line: '13284901413'

Test #10:

score: 10
Accepted
time: 1ms
memory: 3688kb

input:

123456789

output:

1151952165

result:

ok single line: '1151952165'