POJ - 2484 A Funny Game(水+博弈)

点击打开题目链接

 

A Funny Game
Time Limit: 1000MSMemory Limit: 65536K
Total Submissions: 5729Accepted: 3568

Description

Alice and Bob decide to play a funny game. At the beginning of the game they pick n(1 <= n <= 106) coins in a circle, as Figure 1 shows. A move consists in removing one or two adjacent coins, leaving all other coins untouched. At least one coin must be removed. Players alternate moves with Alice starting. The player that removes the last coin wins. (The last player to move wins. If you can't move, you lose.) 

 
Figure 1


Note: For n > 3, we use c1, c2, ..., cn to denote the coins clockwise and if Alice remove c2, then c1 and c3 are NOT adjacent! (Because there is an empty place between c1 and c3.) 

Suppose that both Alice and Bob do their best in the game. 
You are to write a program to determine who will finally win the game.

Input

There are several test cases. Each test case has only one line, which contains a positive integer n (1 <= n <= 106). There are no blank lines between cases. A line with a single 0 terminates the input. 

Output

For each test case, if Alice win the game,output "Alice", otherwise output "Bob". 

Sample Input

1
2
3
0

Sample Output

Alice
Alice
Bob

Source

POJ Contest,Author:Mathematica@ZSU

[Submit]   [Go Back]   [Status]   [Discuss]

这种坑题真是没话说,我开始一直在讨论奇数偶数的问题,还试图从1开始找规律,然后还贡献了一次WA。然后看他们瞬间AC,代码长度200+。(TAT)

题目大意:两个人从桌子上拿硬币,可以拿一个也可以拿相邻的两个,最后一个拿的人胜利。

思路:①当硬币数为1或2的情况,Alice胜利。

  ②当硬币为偶数的情况,Bob可以完全仿照Alice,在对称位置取相同个数,最后必定Bob胜利。

  ③当硬币为奇数且当Alice最初拿1个的时候,Bob可以在对称位置拿一次两个,于是剩下的个数又为偶数,Bob胜利。

  ④当硬币为奇数且当Alice最初拿2个的时候,Bob可以在对称位置拿一个,于是又是第二种情况,Bob胜利。

所以当硬币数大于等于三的时候,总是Bob胜利。(QAQ)

附上AC代码:(虽然很水=。=!)

#include<bits/stdc++.h>

using namespace std;

int main()
{
    int n;
    while(cin>>n,n)
    {
        if(n<3)cout<<"Alice"<<endl;
        else cout<<"Bob"<<endl;
    }
}

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

Chook_lxk

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值