QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#51074 | #858. GCD vs. XOR | FiresonZ | WA | 917ms | 19228kb | C++17 | 924b | 2022-09-30 15:16:03 | 2022-09-30 15:16:05 |
Judging History
answer
#include<iostream>
#include<array>
#include<algorithm>
#include<cmath>
#include<random>
#include<ctime>
#include<iomanip>
using namespace std;
using gg=long long;
mt19937 RND(time(0));
gg MAX=10000000;
array<gg,2000010> num,tp;
inline gg gcd(const gg &a,const gg &b){return b==0?a:gcd(b,a%b);}
inline gg rnd(const gg &l,const gg &r){
return RND()%(r-l+1)+l;
}
int main(){
ios::sync_with_stdio(false);
cin.tie(0);
gg T,n,t,tmp;
double ans;
cin>>T;
MAX/=T;
for(gg i=1;i<=2000000;i++){
tp[i]=tp[i-1]+i-1;
}
while(T--){
cin>>n;
if(n==1){
cout<<0<<'\n';
continue;
}
tmp=0;
for(gg i=1;i<=n;i++){
cin>>num[i];
}
for(gg i=1;i<=MAX;i++){
gg x=rnd(1,n);
gg y=rnd(1,n);
while(x==y) y=rnd(1,n);
if(y<x) swap(x,y);
if(gcd(num[x],num[y])==(num[x]^num[y])) tmp++;
}
ans=double(tmp)/MAX;
cout<<gg(round(ans*tp[n]))<<'\n';
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 637ms
memory: 19212kb
input:
1 4 2 3 4 3
output:
2
result:
ok 1 number(s): "2"
Test #2:
score: -100
Wrong Answer
time: 917ms
memory: 19228kb
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 36 1 3 8 8 347 15 0
result:
wrong answer 13th numbers differ - expected: '37', found: '36'