QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#643393#7679. Master of Both IVsw7777WA 3ms14612kbC++171021b2024-10-15 20:59:102024-10-15 20:59:10

Judging History

你现在查看的是最新测评结果

  • [2024-10-15 20:59:10]
  • 评测
  • 测评结果:WA
  • 用时:3ms
  • 内存:14612kb
  • [2024-10-15 20:59:10]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
const int mod=998244353;
const int N=4e5+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=1;i<=n;i++){
		for(int j=0;j<=2*n;j+=i) g[j].push_back(i); 
	}
	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(){
	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: 0
Wrong Answer
time: 3ms
memory: 14612kb

input:

2
3
1 2 3
5
3 3 5 1 1

output:

4
143

result:

wrong answer 2nd numbers differ - expected: '11', found: '143'