标签:
Description
Input
Output
Sample Input
2 3 4 0
Sample Output
Alice Bob Alice
Hint
无
//思维题,简单博弈,直接插入走火入魔的题解。。。
//AC代码【递归写法】:
#include"algorithm" #include"iostream" #include"cstring" #include"cstdlib" #include"cstdio" #include"string" #include"vector" #include"queue" #include"cmath" #include"map" using namespace std; typedef long long LL ; #define memset(x,y) memset(x,y,sizeof(x)) #define memcpy(x,y) memcpy(x,y,sizeof(x)) #define FK(x) cout<<"["<<x<<"]\n" #define bigfor(T) for(int qq=1;qq<= T ;qq++) #define lson l,m,rt<<1 #define rson m+1,r,rt<<1|1 int fun(int n) { int i=1; while(i<n) { i=i*2+1; if(i==n) return 1; } return 0; } int main() { int n; while(~scanf("%d",&n)) { if(!n)break; if(fun(n)) printf("Bob\n"); else printf("Alice\n"); } }
//AC代码【幂写法】:
#include"algorithm" #include"iostream" #include"cstring" #include"cstdlib" #include"cstdio" #include"string" #include"vector" #include"queue" #include"cmath" #include"map" using namespace std; typedef long long LL ; #define memset(x,y) memset(x,y,sizeof(x)) #define memcpy(x,y) memcpy(x,y,sizeof(x)) #define FK(x) cout<<"["<<x<<"]\n" #define bigfor(T) for(int qq=1;qq<= T ;qq++) #define lson l,m,rt<<1 #define rson m+1,r,rt<<1|1 int main() { int n; while(~scanf("%d",&n)) { if(!n)break; if(n%2==0) { puts("Alice"); continue; } n+=1; while(n) { if(n==1) { puts("Bob"); break; } if(n%2) { puts("Alice"); break; } n/=2; } } return 0; }
标签:
原文地址:http://www.cnblogs.com/HDMaxfun/p/5782463.html