WA on #34 求调
查看原帖
WA on #34 求调
760655
tkdqmx楼主2024/8/19 18:23
#include<bits/stdc++.h>
using namespace std;
#define LL long long
int n,a[100005];
const LL mod=1e9+7;
const int p[]={2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67};
LL quick_pow(LL x,LL y){
	LL res=1;
	while(y){
		if(y&1)  res=res*x%mod;
		x=x*x%mod,y>>=1;
	}
	return res;
}
int main(){
	scanf("%d",&n);
	for(int i=1,x;i<=n;i++){
		scanf("%d",&x);
		for(int j=0;j<19;j++){
			int tot=0;
			while(!(x%p[j]))  x/=p[j],tot++;
			if(tot&1)  a[i]|=1<<j;
		}
	}
	int pos=1;
	for(int i=18;i>=0&&pos<=n;i--){
		int cur=pos;
		while(cur<=n&&!(a[cur]>>i&1))  cur++;
		if(cur>n)   continue;
		if(cur!=i)  swap(a[cur],a[pos]);
		for(int j=1;j<=n;j++)
			if(j!=pos&&a[j]>>i&1)
				a[j]^=a[pos];
		pos++;
	}
	printf("%lld\n",quick_pow(2,n-pos+1)-1);
}
2024/8/19 18:23
加载中...