QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#612744 | #858. GCD vs. XOR | gambit# | WA | 4548ms | 54252kb | C++17 | 1.0kb | 2024-10-05 12:46:53 | 2024-10-05 12:46:53 |
Judging History
answer
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
using namespace std;
typedef long long ll;
const int NN = 2e6+6, MM = 1e6+6;
int T;
int N;
vector<int> child[MM];
ll cnt[MM];
void sol(){
memset(cnt, 0, sizeof(cnt));
cin>>N;
for(int i=0;i<N;i++){
int x;cin>>x;
cnt[x]++;
}
ll ans = 0;
for(int i=0;i<MM;i++){
if(cnt[i]==0)continue;
for(auto c:child[i]){
ans+=cnt[i]*cnt[c];
}
}
cout<<ans<<'\n';
}
int main() {
ios::sync_with_stdio(0); cin.tie(0);
for(int i=1;i<MM;i++){
for(ll j=1;j*j<=i;j++){
if(i%j==0){
if((i^j)==(i+j))child[i].push_back(i+j);
if(j*j!=i&&(i^(i/j))==(i+i/j))child[i].push_back(i+i/j);
}
}
}
// for(int i=1;i<=50;i++){
// cout<<i<<": ";
// for(auto el:child[i])cout<<el<<' ';
// cout<<'\n';
// }
cin>>T;
for(int i=0;i<T;i++)sol();
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 1981ms
memory: 54252kb
input:
1 4 2 3 4 3
output:
2
result:
ok 1 number(s): "2"
Test #2:
score: 0
Accepted
time: 2005ms
memory: 54244kb
input:
20 43 128 66 452 384 400 441 232 203 228 33 284 156 128 190 197 292 388 31 179 343 147 206 450 284 180 73 273 130 168 250 405 203 235 340 309 28 267 395 152 191 295 463 344 54 48 7 12 37 49 24 5 18 15 37 26 57 53 59 22 10 2 16 36 52 64 1 56 42 38 46 53 7 2 8 60 38 54 11 19 50 20 61 6 50 27 5 26 3 4 ...
output:
9 54 13 7 8 34 47 11 1 102 6 5 37 1 3 8 8 348 15 0
result:
ok 20 numbers
Test #3:
score: -100
Wrong Answer
time: 4548ms
memory: 54180kb
input:
20 1318434 383714 853663 66866 511925 858736 184314 296349 849141 468962 414270 917939 220934 778184 984811 194692 105206 528188 310859 57152 790101 274637 529663 931099 79533 179471 539390 210762 400829 514992 127623 369248 168711 380204 767781 753089 645551 714964 101060 340524 937457 928656 65201...
output:
248770295294265142 267731445843839371 235781907167787180 218053231398104162 311057674863616940 279866582204223753 202599893690254596 208098627357230864 189421894053864772 315797962498126609 267826251592212350 215872699082395492 202125864925615043 200229749880527341 247063791746187857 311816120894773...
result:
wrong answer 1st numbers differ - expected: '3032046', found: '248770295294265142'