| Task: | Tekijät |
| Sender: | Laakeri |
| Submission time: | 2020-11-06 23:00:14 +0200 |
| Language: | C++ (C++11) |
| Status: | READY |
| Result: | 100 |
| group | verdict | score |
|---|---|---|
| #1 | ACCEPTED | 12 |
| #2 | ACCEPTED | 35 |
| #3 | ACCEPTED | 53 |
| test | verdict | time | group | |
|---|---|---|---|---|
| #1 | ACCEPTED | 0.56 s | 1, 2, 3 | details |
| #2 | ACCEPTED | 0.56 s | 1, 2, 3 | details |
| #3 | ACCEPTED | 0.57 s | 2, 3 | details |
| #4 | ACCEPTED | 0.57 s | 3 | details |
| #5 | ACCEPTED | 0.62 s | 3 | details |
| #6 | ACCEPTED | 0.57 s | 3 | details |
| #7 | ACCEPTED | 0.57 s | 3 | details |
Code
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll c[1010101];
int lol(int x) {
assert(x>=2);
int r=0;
for (int i=2;i*i<=x;i++){
if (x%i==0){
r++;
x/=i;
}
if (x%i==0){
return 0;
}
}
if (x>1) r++;
if (r%2==1) {
return 1;
} else {
return -1;
}
}
ll ch(ll x) {
return x*(x-1ll)/2ll;
}
int main(){
ios_base::sync_with_stdio(0);
cin.tie(0);
int n;
cin>>n;
for (int i=0;i<n;i++){
int x;
cin>>x;
c[x]++;
}
ll ans=0;
for (int i=2;i<=1000000;i++){
ll f=0;
for (int j=i;j<=1000000;j+=i) {
f+=c[j];
}
ans += ch(f)*(ll)lol(i);
}
cout<<ch(n)-ans<<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 |
