A Funny Game
Time Limit: 1000MS   Memory Limit: 65536K
Total Submissions: 3861   Accepted: 2311

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
 
当N <= 2 时,必定是alice 赢 否则,bob只有吧剩下的个数取到偶数就必胜。
 
 #include <iostream>
#include <cstdio> using namespace std; int N;
int main()
{
while(~scanf("%d",&N) && N) {
printf("%s\n",N <= ? "Alice" : "Bob");
}
//cout << "Hello world!" << endl;
return ;
}

POJ 2484的更多相关文章

  1. POJ 2484(对称博弈)

    题目链接:http://poj.org/problem?id=2484 这道题目大意是这样的,有n个硬币围成一圈,两个人轮流开始取硬币(假设他们编号从1到n),可以选择取一枚或者取相邻的两枚(相邻是指 ...

  2. POJ 2484 A Funny Game 博弈论 对称博弈

    http://poj.org/problem?id=2484 1和2时Alice必胜,3时Bob必胜,其他情况下Bob只需要在Alice取过之后取一次将剩下的硬币链平均分为两份,然后Alice怎么取B ...

  3. POJ 2484 A Funny Game【博弈】

    相比数据结构的题..感觉这种想啊想的题可爱多了~~~代码量还少.... 题目链接: http://poj.org/problem?id=2484 题意: 一圈n个硬币,两人轮流从中取一或两个硬币,(只 ...

  4. poj 2484 A Funny Game(博弈)

    A Funny Game Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 4639   Accepted: 2855 Desc ...

  5. POJ 2484 A Funny Game(智商博弈)

    Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 6397   Accepted: 3978 Description Alice ...

  6. POJ 2484 A Funny Game(博弈论)

    题目链接: 传送门 A Funny Game Time Limit: 1000MS     Memory Limit: 10000K Description Alice and Bob decide ...

  7. 【POJ 2484】A Funny Game

    Description Alice and Bob decide to play a funny game. At the beginning of the game they pick n(1 &l ...

  8. POJ 2484 A Funny Game(神题!)

    一开始看这道博弈题的时候我就用很常规的思路去分析了,首先先手取1或者2个coin后都会使剩下的coin变成线性排列的长条,然后无论双方如何操作都是把该线条分解为若干个子线条而已,即分解为若干个子游戏而 ...

  9. [原博客] POJ 2484 A Funny Game

    题目链接题意:有n个硬币排成一圈,两个人轮流操作,每次可以取走一个或者相邻的连个硬币(只算最开始相邻的,取之后才相邻的不算),问先手必胜还是必败. 这个题可以证明若n>=3,则先手必败.对称博弈 ...

随机推荐

  1. 《Prism 5.0源码走读》UnityBootstrapper

    UnityBootstrapper (abstract class)继承自Bootstrapper(abstract)类, 在Prism.UnityExtensions.Desktop project ...

  2. webpack 学习笔记 02 快速入门

    webpack 的目标 将依赖项分块,按需加载. 减少web app的初始加载时间. 使每一个静态集合都能够作为组件使用. 有能力集成第三方库,作为组件使用. 高度可配置化. 适用于大型项目. INS ...

  3. Map和HashMap

    通过查询JDK帮助文档,我们可以得知Map的说明.方法等 import java.util.Map; import java.util.HashMap; class Test{ public stat ...

  4. Objective-C关于分类、扮演、协议

    -----<a href="http://www.itheima.com" target="blank">Java培训.Android培训.iOS培 ...

  5. C扩展 C++回顾到入门

    引言 C扩展也称C++, 是一个复(za)杂(ji)优(ken)秀(die)的语言. 本文通过开发中常用C++方式来了解和回顾C++这么语言. C++看了较多的书但还是觉得什么都不会. 只能说自己还付 ...

  6. Stream,Reader/Writer,Buffered的区别(1)

    Stream: 是字节流形式,exe文件,图片,视频等.支持8位的字符,用于 ASCII 字符和二进制数据. Reader/Writer: 是字符流,文本文件,XML,txt等,用于16位字符,也就是 ...

  7. with check option

    通过有with check option选项的视图操作基表(只是面对单表,对连接多表的视图正在寻找答案),有以下结论:首先视图只操作它可以查询出来的数据,对于它查询不出的数据,即使基表有,也不可以通过 ...

  8. 【转载】FPGA静态时序分析——IO口时序

    转自:http://www.cnblogs.com/linjie-swust/archive/2012/03/01/FPGA.html 1.1  概述 在高速系统中FPGA时序约束不止包括内部时钟约束 ...

  9. 三,samba

    转载:http://www.cnblogs.com/phinecos/archive/2009/06/06/1497717.html 一. samba的安装: sudo apt-get insall  ...

  10. java中字符串String 转 int(转)

    java中字符串String 转 int String -> int s="12345"; int i; 第一种方法:i=Integer.parseInt(s); 第二种方法 ...