Alice and Bob's Silly Game

  • + 0 comments

    Linear Sieve+Prefix Sums

    void sive(){
    	memset(lp,0,sizeof lp);
    	for (int i=2; i<=N; ++i) {
    	if (lp[i] == 0) {
    		lp[i] = i;
    		pr.push_back (i);
    	}
    	for (int j=0; j<(int)pr.size() && pr[j]<=lp[i] && i*pr[j]<=N; ++j){
    		lp[i * pr[j]] = pr[j];
    	}
        }
        a[0]=a[1]=0;
        for(int i=2;i<mxn;i++){
            if(lp[i]==i){
                a[i]=a[i-1]+1;
                continue;
            }
            a[i]=a[i-1];
        }
    }
    void test_case(){
    	int n,cnt=0;
    	read(n);
    	if(n<2){
    		cout<<"Bob"<<endl;
    		return;
    	}
    	cnt=a[n];
    	cout<<(cnt&1?"Alice":"Bob")<<endl;
    }
    int main(){
    	int tt;
        sync();
    	read(tt);
    	sive();
    	while(tt--){
    		test_case();
    	}
    }