Task: | Tekijät |
Sender: | Lieska |
Submission time: | 2020-11-06 20:13:46 +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.08 s | 1, 2, 3 | details |
#2 | ACCEPTED | 0.07 s | 1, 2, 3 | details |
#3 | ACCEPTED | 0.10 s | 2, 3 | details |
#4 | ACCEPTED | 0.10 s | 3 | details |
#5 | ACCEPTED | 0.13 s | 3 | details |
#6 | ACCEPTED | 0.24 s | 3 | details |
#7 | ACCEPTED | 0.09 s | 3 | details |
Compiler report
input/code.cpp: In function 'int main()': input/code.cpp:37:28: warning: comparison between signed and unsigned integer expressions [-Wsign-compare] for (int k=0; k<v.size(); ++k){ ~^~~~~~~~~
Code
#include <bits/stdc++.h> using namespace std; typedef long long ll; ll t[1111000], jakajia[1111000], r[1111000], pot2[11]; int main(){ ios_base::sync_with_stdio(0); cin.tie(0); //Älä käytä, jos tehtävä on interaktiivinen! for (int i=2; i<=1000000; ++i){ if (t[i]==0){ jakajia[i]=1; for (int j=i*2; j<=1000000; j+=i) { t[j]=i; jakajia[j]++; } } } pot2[1]=2; for (int i=2; i<=10; ++i) pot2[i]=pot2[i-1]*2; ll n; cin >> n; ll a; for (int i=1; i<=n; ++i){ cin >> a; vector<int> v; while (t[a]){ if (v.size()==0 || v[v.size()-1]!=t[a]) v.push_back(t[a]); a = a/t[a]; } if (a>1 && (v.size()==0 || v[v.size()-1]!=a)) v.push_back(a); for (int j=1; j<pot2[v.size()]; ++j){ int b=1; for (int k=0; k<v.size(); ++k){ if (j&(1<<k)){ b*=v[k]; } } r[b]++; } } ll yhttek=0; for (int i=2; i<=1000000; ++i){ if (jakajia[i]%2==1) yhttek+=r[i]*(r[i]-1)/2; else yhttek-=r[i]*(r[i]-1)/2; } cout << n*(n-1)/2-yhttek << "\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 |