题意描述:有一个n个硬币摆成的环,Alice和Bob每次从里面取出一个或两个硬币,Alice先手,谁取到最后一个硬币谁就赢。

解题思路:这是一道对称博弈问题,如果硬币的数量小于等于2,Alice可以一下子拿走,数量大于2的时候,无论Alice拿1个还是两个,Bob都可以根据剩下硬币数量的奇偶性来决定拿1个还是2个,从而使得留给Alice的硬币数量为偶数(取走1个和2个,分别可以改变数量和保持数量的奇偶性),之后无论Alice取几个,Bob只需取同样的个数就能够取胜了。

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

AC代码

#include<stdio.h>              //对称博弈
#include<iostream>
using namespace std;
int main()
{int n;while(~scanf("%d",&n)&&n){if(n>2)printf("Bob\n");elseprintf("Alice\n");}    return 0;
} 

努力努力再努力

【POJ 2484】A Funny Game(对称博弈)相关推荐

  1. codeforces1700数学:E2. Close Tuples (hard version)[组合计数 逆向统计] D. Circle Game[对称博弈考虑对称状态的胜负]

    E2. Close Tuples (hard version) 题目大意: 给定一个长度为n的序列a,给定一个长度为n的序列a,给定一个长度为n的序列a, 要从中挑选一个m元组(ai1,ai2,ai3 ...

  2. poj 2484 A Funny Game

    题目:http://poj.org/problem? id=2484 一,题意: n个硬币围成一个圈,Alice与Bob轮流从圈中取硬币.每次能够取一枚或者连续的两枚. 硬币取走后留下的空位不用填补, ...

  3. POJ 3710 Christmas Game(Tarjan+博弈SG函数)

    [题目链接] http://acm.hust.edu.cn/vjudge/problem/toListProblem.action#OJId=POJ&probNum=3710&titl ...

  4. poj 1740 A New Stone Game 博弈

    题目来源: http://poj.org/problem?id=1740 分析: 均势为:  偶数堆,且 x,x, y,y,z,z... 即先人无论怎么取,后人跟先人一个走法,那么后人一定取最后一堆. ...

  5. 【HDU - 3951】Coin Game (博弈,猜规律,对称博弈)

    题干: After hh has learned how to play Nim game, he begins to try another coin game which seems much e ...

  6. POJ 2348 Euclid's Game(博弈)题解

    题意:有a,b两个数字,两人轮流操作,每次可以选择两个之中较小的数字,然后另一个数字减去选择数字的任意倍数(不能减到负数),直到其中一个为0,不能操作为败 思路:这题用博弈NP思想,必败点和必胜点之间 ...

  7. Calendar Game POJ - 1082(关于日历的博弈问题)

    题意: 两个人轮流玩游戏,每个人可以把日期进行转移,转移规则: 1.可以转移到当前日期的下一天. 2可以转移到下个月的这一天.(但是如果下个月没有这一天就不能进行第二种转移) 3.如果A恰好移动到20 ...

  8. 组合博弈游戏 - SG函数和SG定理

    转载来自:http://blog.csdn.net/luomingjun12315/article/details/45555495 在介绍SG函数和SG定理之前我们先介绍介绍必胜点与必败点吧. 必胜 ...

  9. AI博弈论:DeepMind让智能体在非对称博弈中找纳什均衡

    Root 林鳞 编译自 DeepMind官方博客 量子位 出品 | 公众号 QbitAI 随着人工智能系统在现实世界中扮演越来越重要的角色,理解不同的系统如何相互作用至关重要. 刚刚,DeepMind ...

最新文章

  1. python对笔记本电脑的要求-笔记本电脑中多版本python的配置
  2. angular2 组件之间通讯-使用服务通讯模式 2016.10.27 基于正式版ng2
  3. Linux Kernel 5.10 aarch64体系对TTBR寄存器的设置
  4. pagerank算法实现matlab,Matlab 入门及PageRank算法求解.ppt
  5. HDU2553 N皇后 回溯法+打表
  6. python数据分析函数大全_python中数据分析常用函数整理
  7. 米斯特白帽培训讲义(v2)漏洞篇 第三方风险
  8. Seastar:多核机器上编写高效复杂的服务器应用程序的 C++ 库
  9. ​京东云:原来落地 AI 应用是这么回事儿!
  10. 523. 连续的子数组和
  11. java 成员初始化_静态成员及其初始化
  12. 3cd修改tftp服务器地址,模式tftp服务器是什么
  13. 什么是面向对象对象,什么是面向过程,什么是面向对象思想。
  14. 8051单片机Proteus仿真与开发实例-RS485协议通信仿真
  15. 交换机和集线器的区别
  16. win10一共几个版本,有什么区别?win10版本区别
  17. 概率论基础(3)一维随机变量(离散型和连续型)
  18. Micropython——关于I2C和SoftI2C以及SPI和SoftSPI的区别
  19. iOS开发系列--通讯录、蓝牙、内购、GameCenter、iCloud、Passbook系统服务开发汇总...
  20. 打破构图的平衡!增强设计感染力

热门文章

  1. C printf() 详解之终极无惑
  2. 计算机安全会议2017,科学网-第四届中国密码学与数据安全学术会议(CCDS2017)在衡阳师院召开-李浪的博文...
  3. 小白机器学习笔记(一)
  4. IIS配置webp后缀文件
  5. 哔哩哔哩前端笔试(卷1)
  6. 大华摄像头,NVR取流规则
  7. 一文入门车载以太网,吐血整理!不看后悔!
  8. 批量添加用户脚本--Linux bash
  9. linux用户自动输入密码,Linux自动输入密码登录用户
  10. HDR视频色调映射算法(之二:Adaptive temporal TMO)