Alice and Bob |
accepted:174 |
|
submit:342 |
Time limit:1000 MS |
|
Memory limit:65536 KB |
problem Description
The famous "Alice and Bob" are playing a game again. So is comes the new problem which need a person smart as you to decide the winner. The problem is as Follows:they be playing on a rectangle paper, Alice and Bob take turn alternatively, for each turn, a P Eople cut the rectangle vertically or horizontally, the result of both rectangle after cut must be identical, also the side MU St is integer, after the cut, one rectangle'll be descarded. The first people fail to cut lose the game. Of course, Alice makes first as usual. Input
First line contains an integer t indicate there is t cases (1≤t≤1000) for each case:the input consists of the integers w an D h (1≤w,h≤1,000,000,000), the size of rectangle. Output
First output case numberfor each case output Alice or BOB, indicate the winner. Sample Input
2
1 2)
2 2
Sample Output
Case 1:alice Case
2:bob
SourceXTU Onlinejudge
Analytical:
Simple game. Because it is evenly divided, you only need to determine the number of W and H containing factor 2.
AC Code:
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
int main () {
int t;
LL W, H;
scanf ("%d", &t);
for (int i=1; i<=t; i++) {
scanf ("%lld%lld", &w, &h);
int ans = 0;
while (w% 2 = = 0) {ans + +; w/= 2;}
while (h% 2 = = 0) {ans + +; h/= 2;}
printf ("Case%d:%s\n", I, ans% 2?) "Alice": "Bob");
return 0;
}