Task: | Tekijät |
Sender: | Metabolix |
Submission time: | 2020-11-07 23:14:36 +0200 |
Language: | C++ (C++17) |
Status: | READY |
Result: | 100 |
group | verdict | score |
---|---|---|
#1 | ACCEPTED | 12 |
#2 | ACCEPTED | 35 |
#3 | ACCEPTED | 53 |
test | verdict | time | group | |
---|---|---|---|---|
#1 | ACCEPTED | 0.03 s | 1, 2, 3 | details |
#2 | ACCEPTED | 0.04 s | 1, 2, 3 | details |
#3 | ACCEPTED | 0.06 s | 2, 3 | details |
#4 | ACCEPTED | 0.15 s | 3 | details |
#5 | ACCEPTED | 0.32 s | 3 | details |
#6 | ACCEPTED | 0.36 s | 3 | details |
#7 | ACCEPTED | 0.40 s | 3 | details |
Code
#include <bits/stdc++.h> #define N 1000001 int p[N], dp[N]; long jaettavia[N]; int main() { int n; dp[1] = 1; for (int i = 2; i < N; ++i) { if (!p[i]) for (int j = i; j < N; j += i) { if (!p[j]) { p[j] = i; } } if (p[i / p[i]] == p[i]) { dp[i] = 0; } else { dp[i] = -1 * dp[i / p[i]]; } } std::cin >> n; std::vector<int> luvut(n); for (int i = 0; i < n; ++i) { std::cin >> luvut[i]; int l = luvut[i]; for (int j = (int)sqrt(l); j; j--) { if (l % j == 0) { jaettavia[j] += 1; if (j*j != l) { jaettavia[l/j] += 1; } } } } long tulos = 0; for (int x = 1; x <= 1000000; ++x) { tulos += dp[x] * (jaettavia[x] * (jaettavia[x] - 1) / 2); } std::cout << tulos << std::endl; }
Test details
Test 1
Group: 1, 2, 3
Verdict: ACCEPTED
input |
---|
100 1 2 3 4 5 6 7 8 9 10 11 12 13 ... |
correct output |
---|
3043 |
user output |
---|
3043 |
Test 2
Group: 1, 2, 3
Verdict: ACCEPTED
input |
---|
100 71 19 26 18 57 78 80 89 31 26 ... |
correct output |
---|
3086 |
user output |
---|
3086 |
Test 3
Group: 2, 3
Verdict: ACCEPTED
input |
---|
100000 66 87 90 67 93 89 57 29 34 4 8... |
correct output |
---|
3044751906 |
user output |
---|
3044751906 |
Test 4
Group: 3
Verdict: ACCEPTED
input |
---|
100000 1 2 3 4 5 6 7 8 9 10 11 12 13 ... |
correct output |
---|
3039650753 |
user output |
---|
3039650753 |
Test 5
Group: 3
Verdict: ACCEPTED
input |
---|
100000 238907 151373 522599 885657 37... |
correct output |
---|
3031155756 |
user output |
---|
3031155756 |
Test 6
Group: 3
Verdict: ACCEPTED
input |
---|
100000 510510 510510 510510 510510 51... |
correct output |
---|
0 |
user output |
---|
0 |
Test 7
Group: 3
Verdict: ACCEPTED
input |
---|
100000 999983 999983 999983 999983 99... |
correct output |
---|
0 |
user output |
---|
0 |