Task: | Tekijät |
Sender: | ArktinenKarpalo |
Submission time: | 2020-11-07 03:37:57 +0200 |
Language: | C++ (C++17) |
Status: | READY |
Result: | 47 |
group | verdict | score |
---|---|---|
#1 | ACCEPTED | 12 |
#2 | ACCEPTED | 35 |
#3 | TIME LIMIT EXCEEDED | 0 |
test | verdict | time | group | |
---|---|---|---|---|
#1 | ACCEPTED | 0.04 s | 1, 2, 3 | details |
#2 | ACCEPTED | 0.04 s | 1, 2, 3 | details |
#3 | ACCEPTED | 0.12 s | 2, 3 | details |
#4 | ACCEPTED | 0.24 s | 3 | details |
#5 | ACCEPTED | 0.34 s | 3 | details |
#6 | TIME LIMIT EXCEEDED | -- | 3 | details |
#7 | ACCEPTED | 0.10 s | 3 | details |
Compiler report
input/code.cpp: In function 'long long int brute(std::vector<long long int>)': input/code.cpp:102:16: warning: comparison between signed and unsigned integer expressions [-Wsign-compare] for(int i=0; i<v.size(); i++) { ~^~~~~~~~~ input/code.cpp:103:19: warning: comparison between signed and unsigned integer expressions [-Wsign-compare] for(int j=i+1; j<v.size(); j++) ~^~~~~~~~~
Code
#include <bits/stdc++.h> #define ll long long #define ld long double #define M 1000000007 using namespace std; vector<ll> P; int c = 0; int prm[1010101]; ll ans = 0; vector<ll> tek[1010101]; bool prime(ll x) { return !prm[x]; } int z[1010101]; ll dd[1010101]; ll cnt[1010101]; vector<ll> dh; void haku1(ll s, ll pr, ll d) { ll d2 = d; queue<ll> q; queue<ll> q2; q2.push(s); vector<pair<int,int>> dv; map<ll,ll> mp; lol: d += d2; d2 = 0; q = q2; q2 = {}; while(!q2.empty()) q2.pop(); while(!q.empty()) { s = q.front(); q.pop(); int qq = 0; for(auto u:mp) { if(u.first%s == 0) qq +=u.second; } ll lk = cnt[s]-qq; ans -= lk; cnt[s]++; assert(s>1); if(lk) mp[s]+=lk; for(auto u:tek[pr]) { if(u < s && s%u == 0) { if(z[s/u] == c) { continue; } else { z[s/u] = c; } q2.push(s/u); } } } if(!q2.empty()) { goto lol; } } int cntt = 0; int mx = 0; void pr(ll x) { ll sm = 1; if(x == 1) return; vector<ll> v; if(prime(x)) { sm = x; } else { while(x > 1) { ll lk = prm[x]; if(lk == 0) { sm *= x; v.push_back(x); break; } if(v.size() == 0 || v[v.size()-1] != lk) { sm *= lk; v.push_back(lk); } x /= lk; } } tek[sm] = v; assert(sm>1); haku1(sm, sm, 0); //cnt[sm]++; } ll brute(vector<ll> v) { ll ret = 0; for(int i=0; i<v.size(); i++) { for(int j=i+1; j<v.size(); j++) if(__gcd(v[i], v[j]) == 1) ret++; } return ret; } int main() { cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(); prm[1] = 1; for(ll i=2; i<=1000000; i++) { if(!prm[i]) { P.push_back(i); for(ll j=2; j*i<=1e6; j++) if(!prm[i*j]) prm[i*j] = i; } } ll n; cin >> n; ans = n*(n-1)/2; vector<ll> bv; for(int i=0; i<n; i++) { int x; cin >> x; bv.push_back(x); c = i+1; pr(x); } cnt[1] = 0; cout << 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: TIME LIMIT EXCEEDED
input |
---|
100000 510510 510510 510510 510510 51... |
correct output |
---|
0 |
user output |
---|
(empty) |
Test 7
Group: 3
Verdict: ACCEPTED
input |
---|
100000 999983 999983 999983 999983 99... |
correct output |
---|
0 |
user output |
---|
0 |