A Funny Game
Time Limit: 1000MS   Memory Limit: 65536K
Total Submissions: 5401   Accepted: 3381

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

题意:环,取1或2个相邻的

Alice取完后变成链了,可以先递推链的(利用N和P的关系)
发现全是N状态
所以只有1 2时Alice,否则Bob
 
题解是这么分析的:
典型的对称博弈。当n>=3时,无论A如何选择,B选择一个特殊的位置(1个或者连续2个)正好把剩下的环路分成两个链路,大小相同。接下来,无论A选择两个链路中哪一个,进行何种操作,B只需要选择另一个链路中,进行相同的操作。剩下的系统,仍是对称的。直到最后,B肯定是最后一个进行操作的。
#include <cstdio>
inline int read(){
char c=getchar();int x=,f=;
while(c<''||c>''){if(c=='-')f=-;c=getchar();}
while(c>=''&&c<=''){x=x*+c-'';c=getchar();}
return x*f;
}
int n;
int main(int argc, const char * argv[]) {
while((n=read())){
if(n>=) puts("Bob");
else puts("Alice");
}
return ;
}
 
 

POJ2484 A Funny Game[博弈论]的更多相关文章

  1. 【博弈论】poj2484 A Funny Game

    如果当前状态可以根据某条轴线把硬币分成两个相同的组,则当前状态是必败态. 因为不论在其中一组我们采取任何策略,对方都可以采取相同的策略,如此循环,对方必然抽走最后一枚硬币. 因为我们先手,因此抽完后盘 ...

  2. IT人生知识分享:博弈论的理性思维

    背景: 昨天看了<最强大脑>,由于节目比较有争议性,不知为什么,作为一名感性的人,就想试一下如果自己理性分析会是怎样的呢? 过程是这样的: 中国队(3人)VS英国队(4人). 1:李建东( ...

  3. [poj2348]Euclid's Game(博弈论+gcd)

    Euclid's Game Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 9033   Accepted: 3695 Des ...

  4. 博弈论揭示了深度学习的未来(译自:Game Theory Reveals the Future of Deep Learning)

    Game Theory Reveals the Future of Deep Learning Carlos E. Perez Deep Learning Patterns, Methodology ...

  5. TYVJ博弈论

    一些比较水的博弈论...(为什么都没有用到那什么SG呢....) TYVJ 1140  飘飘乎居士拯救MM 题解: 歌德巴赫猜想 #include <cmath> #include < ...

  6. Codeforces 549C. The Game Of Parity[博弈论]

    C. The Game Of Parity time limit per test 1 second memory limit per test 256 megabytes input standar ...

  7. 【POJ】2234 Matches Game(博弈论)

    http://poj.org/problem?id=2234 博弈论真是博大精深orz 首先我们仔细分析很容易分析出来,当只有一堆的时候,先手必胜:两堆并且相同的时候,先手必败,反之必胜. 根据博弈论 ...

  8. 博弈论入门小结 分类: ACM TYPE 2014-08-31 10:15 73人阅读 评论(0) 收藏

    文章原地址:http://blog.csdn.net/zhangxiang0125/article/details/6174639 博弈论:是二人或多人在平等的对局中各自利用对方的策略变换自己的对抗策 ...

  9. poj 3710 Christmas Game 博弈论

    思路:首先用Tarjan算法找出树中的环,环为奇数变为边,为偶数变为点. 之后用博弈论的知识:某点的SG值等于子节点+1后的异或和. 代码如下: #include<iostream> #i ...

随机推荐

  1. for xml path 将单表中一个字段用逗号分隔

    我也是才知道这种用法的,刚好又用到写个简单的例子. select Name from tc_order_detail 如下表,现在要将做到将name每个以逗号连接 declare @df nvarch ...

  2. Delphi 取得 iOS 辅助使用里的字型大小

    说明:在 iOS 里有一个人性化的辅助设定,可以将字体放大,但这个设定对 Delphi 是不起作用的,还好 Delphi 提供了这个 iOS API 可以取得. 开发环境:Delphi 10 Seat ...

  3. Tomcat 8080端口被占用解决方法

    使用lsof命令查看端口占用情况 sudo lsof -i:8080 端口占用情况 java 1564 tomcat8 50u IPv6 19336 0t0 TCP *:http-alt (LISTE ...

  4. jquery插件图片延时加载实例详解

    效果预览:http://keleyi.com/keleyi/phtml/image/index.htm 使用方法:1.导入JS插件 <script src="http://keleyi ...

  5. 如何使用grunt压缩js文件

    jQuery在使用grunt,bootstrap在使用grunt,百度UEditor在使用grunt,你没有理由不学.不用! 1. 前言 各位web前端开发人员,如果你现在还不知道grunt或者听说过 ...

  6. jquery.dataTable.js 基础配置

    $(document).ready(function () { $('#dataTables-example').DataTable({ responsive: true, "bPagina ...

  7. javascript中的一些核心知识点以及需要注意的地方

    前言 近期杂事甚多,这些事情的积累对知识体系的提升有好处,但是却不能整理出来,也整理不出来 比如说我最近研究的Hybrid在线联调方案便过于依赖于业务,就算分享也不会有人读懂,若是抽一点来分享又意义不 ...

  8. Bootstrap之字体图标

    优点:1.减少请求 2.容易控制样式 所在位置:在下载的bootstrap文件中的fonts文件夹存放字体图标 默认路径为当前目录下,如需修改路径,则需在bootstrap.css中查找font-fa ...

  9. 兼容 IE input button 左右内边距的增加

    IE 下的按钮标签(input.button)会随着文字的增加导致文本左右两侧的间距越来越大.该问题存在于 IE6/IE7,IE8~IE10 没发现类似问题.一般情况下,只要给按钮标签设置 overf ...

  10. 安全生产应急救援指挥系统之GIS一张图-flex/java

    开发语言是flex.java,开发平台是myeclise.eclise,后台数据库是oracel或sqlserver,开发接口是arcgis api for flex,提供以下的功能: 1.地图框选搜 ...