Alice and Bob invented the following silly game:
- The game starts with an integer, , that's used to build a of distinct integers in the inclusive range from to (i.e., ).
- Alice always plays first, and the two players move in alternating turns.
- During each move, the current player chooses a prime number, , from . The player then removes and all of its multiples from .
- The first player to be unable to make a move loses the game.
Alice and Bob play games. Given the value of for each game, print the name of the game's winner on a new line. If Alice wins, print
Alice
; otherwise, print Bob
.
Note: Each player always plays optimally, meaning they will not make a move that causes them to lose the game if some better, winning move exists.
Input Format
The first line contains an integer, , denoting the number of games Alice and Bob play.
Each line of the subsequent lines contains a single integer, , describing a game.
Each line of the subsequent lines contains a single integer, , describing a game.
Constraints
Subtasks
- for of the maximum score
Output Format
For each game, print the name of the winner on a new line. If Alice wins, print
Alice
; otherwise, print Bob
.
Sample Input 0
3
1
2
5
Sample Output 0
Bob
Alice
Alice
Explanation 0
Alice and Bob play the following games:
- We are given , so . Because Alice has no valid moves (there are no prime numbers in the set), she loses the game. Thus, we print
Bob
on a new line. - We are given , so . Alice chooses the prime number and deletes it from the set, which becomes . Because Bob has no valid moves (there are no prime numbers in the set), he loses the game. Thus, we print
Alice
on a new line. - We are given , so . Alice chooses the prime number and deletes the numbers and from the set, which becomes . Now there are two primes left, and . Bob can remove either prime from the set, and then Alice can remove the remaining prime. Because Bob is left without a final move, Alice will always win. Thus, we print
Alice
on a new line.
Solution:
- #include <bits/stdc++.h>
- #define pb push_back
- using namespace std;
- typedef long long LL;
- const int S = 100003;
- const int MOD = 1e9+7;
- const double pi = 2 * acos( 0.0 );
- inline int _Int(){ int x; scanf( "%d", &x ); return x; }
- inline LL _LLi(){ LL x; scanf( "%lld", &x ); return x; }
- void pruts(){ puts( "-1" ); exit( EXIT_SUCCESS ); }
- int dirX[] = { 1, 0, -1, 0, 1, -1, 1, -1 };
- int dirY[] = { 0, 1, 0, -1, 1, -1, -1, 1 };
- int rX[] = { 1, 1, 2, 2, -1, -1, -2, -2 };
- int rY[] = { 2, -2, 1, -1, 2, -2, 1, -1 };
- template < class T > T tri_Area( T x1, T y1, T x2, T y2, T x3, T y3 ){ return abs( x1*( y2-y3 ) - y1*( x2-x3 ) + ( x2*y3-x3*y2 ) );};
- template < class T > T Distance( T x1, T y1, T x2, T y2 ){ return sqrt( ( x1-x2 ) * ( x1-x2 ) + ( y1-y2 ) * ( y1-y2 ) ); };
- template < class T > T bigMod( T n, T p, T m ){ if( p == 0 )return 1; if( p&1 )return ( n*bigMod( n, p-1, m ) )%m; T x = bigMod( n, p/2, m ); return ( x*x )%m; };
- int sset(int N, int pos){return N=N|(1<<pos);}
- bool check(int N, int pos){return (bool)(N&(1<<pos));}
- int reset(int N, int pos){return N=N&~(1<<pos);}
- /*******************###########################################********************
- ********************## MD. YA-SEEN ARAFAT(ThunderStroke) ##********************
- ********************## CSE, University of Asia Pacific ##********************
- ********************###########################################********************/
- int prime[ S ];
- int freq[ S ];
- void seive(){
- int sq = sqrt(S);
- for( int i = 2; i <= sq; i++ ){
- if( !prime[ i ] ){
- for( int j = i+i; j <= S; j += i )prime[ j ] = 1;
- }
- }
- for( int i = 2; i < S; i++ ){
- if( !prime[ i ] )freq[ i ]++;
- freq[ i ] += freq[ i-1 ];
- }
- }
- void Love(){
- seive();
- int g = _Int();
- while( g-- ){
- int n = _Int();
- puts( ( freq[ n ]&1 )? "Alice" : "Bob" );
- }
- }
- int main(){
- #ifndef ONLINE_JUDGE
- // freopen("in.txt", "r", stdin);
- // freopen("n.txt", "w", stdout);
- #endif
- Love();
- return 0;
- }
No comments:
Post a Comment