QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#316571#7679. Master of Both IVHqwqWA 74ms39380kbC++141.1kb2024-01-27 21:57:502024-01-27 21:57:51

Judging History

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

  • [2024-01-27 21:57:51]
  • 评测
  • 测评结果:WA
  • 用时:74ms
  • 内存:39380kb
  • [2024-01-27 21:57:50]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;

long long t,n,a[200010],d[100],f[200010],mod=998244353;
long long ans;
vector<long long>b[200010];

long long qmi(long long a,long long p){
	long long res=1;
	while(p){
		if (p&1) res=res*a%mod;
		a=a*a%mod;
		p>>=1;
	}
	return res%mod;
}

int add(int x){
	for (int i=20;i>=0;i--){
		if (x&(1<<i)){
			if (d[i]) x^=d[i];
			else {
				d[i]=x;
				return 1;
			}
		}
	}
	return 0;
}	

int main(){
	for (int i=1;i<=200000;i++){
		for (int j=i*2;j<=200000;j+=i){
			b[j].push_back(i);
		}
	}
	scanf("%lld",&t);
	while(t--){
		ans=0;
		for (int i=0;i<=20;i++) d[i]=0;
		scanf("%lld",&n);
		for (int i=1;i<=n;i++) f[i]=0;
		long long r=0,cnt;
		for (int i=0;i<=n;i++){
			scanf("%lld",&a[i]);
			if (add(a[i])) r++;
			f[a[i]]++;
		}
		ans+=qmi(2,n-r);
		for (int i=1;i<=n;i++){
			if (!f[i]) continue;
			for (int j=0;j<=20;j++) d[j]=0;
			r=1;
			cnt=f[i];
			for (int j=0;j<b[i].size();j++){
				if (!f[b[i][j]]) continue;
				if (add(b[i][j])) r++;
				cnt+=f[b[i][j]];
			}
			ans=(ans+qmi(2,cnt-r))%mod;
		}
		printf("%lld\n",(ans+mod-1)%mod);
	}
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Wrong Answer
time: 74ms
memory: 39380kb

input:

2
3
1 2 3
5
3 3 5 1 1

output:

3
4

result:

wrong answer 1st numbers differ - expected: '4', found: '3'