QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#643373 | #7679. Master of Both IV | sw7777 | WA | 3ms | 9044kb | C++17 | 994b | 2024-10-15 20:54:36 | 2024-10-15 20:54:38 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
const int mod=998244353;
const int N=2e5+10;
int n,d[60],pow2[N],rk;
void insert(int x){
for(int i=30;i>=0;i--){
if(x&(1<<i)){
if(d[i]) x^=d[i];
else{
d[i]^=x;
rk++;
return;
}
}
}
}
bool check(int x){
for(int i=30;i>=0;i--){
if(x*(1<<i)){
if(d[i]) x^=d[i];
}
}
return x==0;
}
vector<int> g[N];
int cnt[N];
void sol(){
int n;cin>>n;
for(int i=1;i<=n;i++){
int x;cin>>x;
cnt[x]++;
}
for(int i=1;i<=n;i++){
for(int j=0;j<=2*n;j+=i) g[j].push_back(i);
}
int ans=0;
for(int i=0;i<=2*n;i++){//枚举每个结果
int cc=0;
memset(d,0,sizeof(d));
rk=0;
for(auto fac:g[i]){
if(cnt[fac]){
insert(fac);
cc+=cnt[fac];
}
}
if(check(i)) ans=(ans+pow2[cc-rk])%mod;
}
cout<<ans-1<<endl;
}
int main(){
pow2[0]=1;
for(int i=1;i<=2e5;i++){
pow2[i]=(pow2[i-1]*2)%mod;
}
pow2[0]=1;
int T;cin>>T;while(T--)sol();
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 3ms
memory: 9044kb
input:
2 3 1 2 3 5 3 3 5 1 1
output:
4 5247
result:
wrong answer 2nd numbers differ - expected: '11', found: '5247'