Gym 100952 G. The jar of divisors
G. The jar of divisors
time limit per test
2 secondsmemory limit per test
64 megabytesinput
standard inputoutput
standard outputAlice and Bob play the following game. They choose a number N to play with. The rules are as follows:
- They write each number from 1 to N on a paper and put all these papers in a jar.
- Alice plays first, and the two players alternate.
- In his/her turn, a player can select any available number M and remove its divisors including M.
- The person who cannot make a move in his/her turn wins the game.
Assuming both players play optimally, you are asked the following question: who wins the game?
Input
The first line contains the number of test cases T (1 ≤ T ≤ 20). Each of the next T lines contains an integer (1 ≤ N ≤ 1,000,000,000).
Output
Output T lines, one for each test case, containing Alice if Alice wins the game, or Bob otherwise.
Examples
Input
2
5
1
Output
Alice
Bob
这道题我自己都有点迷茫,是个博弈题,结论就是n%6==1?"Bob":"Alice"
#include <iostream> #include <cstdio> #include <cstring> #include <queue> #include <cmath> #include <map> #include <vector> #include <algorithm> using namespace std; #define lowbit(x) (x&(-x)) #define max(x,y) (x>y?x:y) #define min(x,y) (x<y?x:y) #define MAX 100000000000000000 #define MOD 1000000007 #define PI 3.141592653589793238462 #define INF 0x3f3f3f3f3f #define mem(a) (memset(a,0,sizeof(a))) typedef long long ll; int main() { ll t,n; scanf("%lld",&t); while(t--) { cin>>n; if(n%6==1) puts("Bob"); else puts("Alice"); } return 0; }