2844: albus就是要第一个出场
Time Limit: 6 Sec Memory Limit: 128 MBSubmit: 1729 Solved: 718
[Submit][Status][Discuss]
题目大意:
https://blog.sengxian.com/algorithms/linear-basis
#include<iostream> #include<cstdio> #include<vector> #define maxn 100010 #define mod 10086 using namespace std; int n,a[maxn],q,b[31]; int Pow(int x,int y){ int 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=0;i<n;i++)scanf("%d",&a[i]); scanf("%d",&q); int cnt=0,rnk=0; for(int i=0;i<n;i++) for(int j=30;j>=0;j--) if(a[i]>>j&1){ if(b[j])a[i]^=b[j]; else{ b[j]=a[i]; cnt++; break; } } vector<int>v; for(int i=0;i<=30;i++)if(b[i])v.push_back(i); for(int i=0;i<v.size();i++)if(q>>v[i]&1)rnk+=1<<i; int ans=rnk%mod*Pow(2,n-cnt)%mod; ans=(ans+1)%mod; printf("%d",ans); }