You are viewing a single comment's thread. Return to all comments →
PLEASE HELP!
using namespace std;
ll SIZE = P;
void sieve(set&hash){
vector<bool>prime(SIZE+1,true); prime[0]=prime[1] = false; int i,j; for(i=2;i*i<=SIZE;i++){ if(prime[i]){ for(j=2;j*i<=SIZE;j++) prime[j*i] = false; } } for(i=2;i<=SIZE;i++) if(prime[i]) hash.insert(i);
}
int main(){ sethash; sieve(hash); int q; cin>>q; while(q--){
int n,i,j; cin>>n; vector<int>arr(n); for(i=0;i<n;i++) cin>>arr[i]; int MAX = pow(2,(floor)(log2(*max_element(arr.begin(),arr.end())))+1)-1; vector<vector<bool> >dp(n+1,vector<bool>(MAX+1,false)); for(i=0;i<=n;i++) dp[i][0] = true; for(i=1;i<=n;i++){ dp[i][arr[i-1]]=true; for(j=MAX;j>=1;j--){ if(dp[i-1][j] == true){ dp[i][j] = true; dp[i][j^arr[i-1]]=true; } } } ll cnt=0; for(i=0;i<=MAX;i++) if(dp[n][i] && hash.find(i)!=hash.end()) cnt = (cnt+1)%MOD; cout<<cnt<<"\n"; } return 0;
Seems like cookies are disabled on this browser, please enable them to open this website
Prime XOR
You are viewing a single comment's thread. Return to all comments →
PLEASE HELP!
include
include
using namespace std;
define ll long int
define MOD 1000000007
define P pow(2,13)
ll SIZE = P;
void sieve(set&hash){
}
int main(){ sethash; sieve(hash); int q; cin>>q;
while(q--){
}