QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#643390 | #7679. Master of Both IV | sw7777 | TL | 58ms | 26208kb | C++17 | 1023b | 2024-10-15 20:58:03 | 2024-10-15 20:58:03 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
const int mod=998244353;
const int N=2e5+10;
int 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]++;
}
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;
for(int i=1;i<=n;i++){
cnt[i]=0;
}
}
int main(){
for(int i=1;i<=2e5;i++){
for(int j=0;j<=2e5;j+=i) g[j].push_back(i);
}
pow2[0]=1;
for(int i=1;i<=2e5;i++){
pow2[i]=(pow2[i-1]*2)%mod;
}
int T;cin>>T;while(T--)sol();
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 58ms
memory: 26208kb
input:
2 3 1 2 3 5 3 3 5 1 1
output:
4 11
result:
ok 2 number(s): "4 11"
Test #2:
score: -100
Time Limit Exceeded
input:
40000 5 4 2 5 5 5 5 5 5 5 5 4 5 1 4 4 4 2 5 2 5 2 4 1 5 3 2 4 5 3 5 1 5 5 3 4 5 5 5 5 4 3 5 4 3 3 5 1 5 4 5 5 2 1 5 2 5 4 2 5 5 3 4 3 4 3 5 5 3 5 1 3 5 5 1 2 4 4 5 4 2 5 1 5 5 5 4 2 5 4 5 5 2 5 2 4 5 1 4 5 4 5 5 4 2 3 2 3 5 1 4 1 3 5 5 1 1 2 1 5 5 5 2 5 1 3 5 3 1 2 5 3 5 5 5 1 1 5 5 2 2 2 1 3 5 3 1 ...
output:
9 16 9 9 8 8 9 8 8 9 13 8 8 8 8 9 12 9 11 15 8 8 17 13 8 11 8 8 8 13 15 9 9 8 8 8 11 9 11 13 15 9 17 9 8 8 8 13 11 8 9 11 8 8 11 15 9 8 9 8 8 15 11 8 17 9 15 8 8 8 12 9 9 11 8 13 9 8 15 8 8 9 8 8 8 15 8 11 13 8 9 11 8 19 11 13 19 17 13 15 8 8 8 9 8 9 13 15 17 9 9 17 9 11 9 9 11 9 9 11 8 9 9 13 15 11...