QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#51073 | #858. GCD vs. XOR | FiresonZ | WA | 339ms | 19192kb | C++17 | 922b | 2022-09-30 15:14:55 | 2022-09-30 15:14:58 |
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=5000000;
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(ceil(ans*tp[n]))<<'\n';
}
return 0;
}
详细
Test #1:
score: 0
Wrong Answer
time: 339ms
memory: 19192kb
input:
1 4 2 3 4 3
output:
3
result:
wrong answer 1st numbers differ - expected: '2', found: '3'