Task: | Tekijät |
Sender: | hltk |
Submission time: | 2020-11-06 21:42:31 +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.14 s | 3 | details |
#5 | ACCEPTED | 0.29 s | 3 | details |
#6 | ACCEPTED | 0.63 s | 3 | details |
#7 | ACCEPTED | 0.78 s | 3 | details |
Compiler report
input/code.cpp: In function 'int main()': input/code.cpp:14:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result] scanf("%d",&n); ~~~~~^~~~~~~~~ input/code.cpp:18:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result] scanf("%d",&x); ~~~~~^~~~~~~~~
Code
#include<bits/stdc++.h> #define sz(x) ((int)(x).size()) #define all(x) x.begin(),x.end() using namespace std; using pi = pair<int,int>; using lint = long long; const int C = 1e9 + 7; const int MAXL = 8; unordered_map<int, int> cnt[MAXL]; int main(){ int n; scanf("%d",&n); lint ans = 0; for(int i=0; i<n; ++i){ int x; scanf("%d",&x); vector<int> v; for(int y=2; y*y<=x; ++y){ if(x % y == 0) v.push_back(y); while(x % y == 0) x /= y; } if(x != 1) v.push_back(x); lint c = 0; for(int j=1; j<(1<<sz(v)); ++j){ int r = 0; for(int k=0; k<sz(v); ++k){ if((j>>k) & 1) r = r * C + v[k]; } int pop = __builtin_popcount(j); c += cnt[pop][r] * (pop & 1 ? 1 : -1); cnt[pop][r]++; } ans += c; } printf("%lld\n", lint(n) * (n - 1) / 2 - ans); }
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 |