• 博客园logo
  • 会员
  • 周边
  • 新闻
  • 博问
  • 闪存
  • 赞助商
  • YouClaw
    • 搜索
      所有博客
    • 搜索
      当前博客
  • 写随笔 我的博客 短消息 简洁模式
    用户头像
    我的博客 我的园子 账号设置 会员中心 简洁模式 ... 退出登录
    注册 登录
HaibaraAi
博客园    首页    新随笔    联系   管理    订阅  订阅

Uva 12293 - Box Game

你为何这么叼!

Box Game 

Time limit: 1.000 seconds

 

There are two identical boxes. One of them contains n balls, while the other box contains one ball. Alice and Bob invented a game with the boxes and balls, which is played as follows:

Alice and Bob moves alternatively, Alice moves first. For each move, the player finds out the box having fewer number of balls inside, and empties that box (the balls inside will be removed forever), and redistribute the balls in the other box. After the redistribution, each box should contain at least one ball. If a player cannot perform a valid move, he loses. A typical game is shown below:

\epsfbox{p12293.eps}

When both boxes contain only one ball, Bob cannot do anything more, so Alice wins.


Question: if Alice and Bob are both clever enough, who will win? Suppose both of them are very smart and always follows a perfect strategy.

Input 

There will be at most 300 test cases. Each test case contains an integer n ( 2$ \le$n$ \le$109) in a single line. The input terminates by n = 0.

Output 

For each test case, print a single line, the name of the winner.

Sample Input 

2
3
4
0

Sample Output 

Alice
Bob
Alice

 


The Seventh Hunan Collegiate Programming Contest
Problemsetter: Rujia Liu, Special Thanks: Yiming Li & Jane Alam Jan

 

 1 #include <cstdio>
 2 #include <cstring>
 3 #include <algorithm>
 4 using namespace std;
 5 #define maxn 61
 6 int n,m,k;
 7 int a[maxn];
 8 int main(){
 9     for(int i=0;i<30;i++)a[i]=a[i-1]*2+1;
10     while(scanf("%d",&n)&&n){
11         for(k=0;k<30;k++)if(a[k]==n){puts("Bob");break;}
12         if(k==30)puts("Alice");
13     }
14     return 0;
15 }
View Code 2013-10-10 16:53:46 

 

posted @ 2013-10-10 16:55  HaibaraAi  阅读(135)  评论(0)    收藏  举报
刷新页面返回顶部
博客园  ©  2004-2026
浙公网安备 33010602011771号 浙ICP备2021040463号-3