QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#291046 | #4136. Longge 的问题 | MoRanSky | 100 ✓ | 1ms | 3864kb | C++23 | 531b | 2023-12-26 04:36:05 | 2023-12-26 04:36:06 |
Judging History
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'