QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#740541 | #9619. 乘积,欧拉函数,求和 | lywyw | TL | 0ms | 1636kb | C++14 | 880b | 2024-11-13 10:22:23 | 2024-11-13 10:22:24 |
Judging History
answer
#include <stdio.h>
#include <stdlib.h>
#define MOD 998244353
int eulerPhi(int n) {
int result = n;
for (int i = 2; i * i <= n; i++) {
if (n % i == 0) {
while (n % i == 0) {
n /= i;
}
result -= result / i;
}
}
if (n > 1) {
result -= result / n;
}
return result;
}
int a[2000];
int n;
long long result = 0;
void dfs(int step, int sum) {
if (step == n) {
if (sum == 1) {
result = (result + 1) ;
} else {
result = (result + eulerPhi(sum)) ;
}
return;
}
dfs(step + 1, sum);
dfs(step + 1, sum * a[step]);
}
int main() {
scanf("%d", &n);
for (int i = 0; i < n; i++) {
scanf("%d", &a[i]);
}
dfs(0, 1);
printf("%lld\n", result%MOD);
return 0;
}
詳細信息
Test #1:
score: 100
Accepted
time: 0ms
memory: 1636kb
input:
5 1 6 8 6 2
output:
892
result:
ok single line: '892'
Test #2:
score: 0
Accepted
time: 0ms
memory: 1528kb
input:
5 3 8 3 7 8
output:
3157
result:
ok single line: '3157'
Test #3:
score: -100
Time Limit Exceeded
input:
2000 79 1 1 1 1 1 1 2803 1 1 1 1 1 1 1609 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2137 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 613 1 499 1 211 1 2927 1 1 1327 1 1 1123 1 907 1 2543 1 1 1 311 2683 1 1 1 1 2963 1 1 1 641 761 1 1 1 1 1 1 1 1 1 1 1 1489 2857 1 1 1 1 1 1 1 1 1 1 1 1 1 967 1 821 1 1 1 1 2143 1861...