Task: | Tekijät |
Sender: | Sisuaski |
Submission time: | 2020-11-07 18:56:39 +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.01 s | 1, 2, 3 | details |
#2 | ACCEPTED | 0.01 s | 1, 2, 3 | details |
#3 | ACCEPTED | 0.04 s | 2, 3 | details |
#4 | ACCEPTED | 0.06 s | 3 | details |
#5 | ACCEPTED | 0.08 s | 3 | details |
#6 | ACCEPTED | 0.11 s | 3 | details |
#7 | ACCEPTED | 0.10 s | 3 | details |
Code
#include <iostream> using namespace std; const int MN = 1<<17; const int MX = 1<<20; int xs[MN]; int ps[MX]; bool nonp[MX]; int counts[MX]; int fs[32]; int go(int x, int f, int c) { if (f<0) return counts[x]++ * c; return go(x, f-1, c) + go(x*fs[f], f-1, -c); } int main() { int P=0; for(int i=2; i<MX; ++i) if (!nonp[i]) { ps[P++] = i; for(int j=2*i; j<MX; j+=i) nonp[j]=1; } int n;cin>>n; long long res=0; while(n--) { int x;cin>>x; int f=0; for(int i=0; x>1; ++i) { int p = ps[i]; if (x%p==0) { do x/=p; while(x%p==0); fs[f++] = p; } else if (p*p>x) break; } if (x>1) fs[f++] = x; res += go(1, f-1, 1); } cout<<res<<'\n'; }
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 |