POJ 2484 A Funny Game(博弈论)

时间:2022-11-24 01:04:47

题目链接: 传送门

A Funny Game

Time Limit: 1000MS     Memory Limit: 10000K

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.)
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

解题思路

这类问题,其实可以根据对称性来接,Alice先手,所以Bob可以根据链的奇偶性取走一枚或两枚硬币,然后分成两个长度相同的链,每次取走硬币与Alice相同,最后必然是Bob最后取走。

#include<cstdio>

int main()
{
    int N;
    while (~scanf("%d",&N) && N)
    {
        if (N <= 2)
        {
            printf("Alice\n");
        }
        else
        {
            printf("Bob\n");
        }
    }
    return 0;
}

POJ 2484 A Funny Game(博弈论)的更多相关文章

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

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

  2. POJ&period;1067 取石子游戏 &lpar;博弈论 威佐夫博弈&rpar;

    POJ.1067 取石子游戏 (博弈论 威佐夫博弈) 题意分析 简单的威佐夫博弈 博弈论快速入门 代码总览 #include <cstdio> #include <cmath> ...

  3. POJ 2484(对称博弈)

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

  4. POJ 2348 Euclid&&num;39&semi;s Game 博弈论

    http://poj.org/problem?id=2348 顺便说,必应翻译真的好用,比谷歌翻译好用100倍. 很难判断这道题的具体博弈类型. 有两种写法,一种是找规律,一种是推理得到关系后循环(或 ...

  5. POJ 2484 A Funny Game【博弈】

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

  6. &lbrack;poj 3537&rsqb;Crosses and Crosses&lpar;博弈论)

    题目:http://poj.org/problem?id=3537 题意:给你n个格子,两个人依次在n个格子的任意空位置画"X",谁如果画了一个后,3个X连在了一起,那么那个人就获 ...

  7. POJ 2484

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

  8. poj 2484 A Funny Game(博弈)

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

  9. POJ 2484 A Funny Game&lpar;智商博弈&rpar;

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

随机推荐

  1. css3之3d导航

    css3的新属性非常不错,目前IE除外其他浏览器都已支持 实现原理:比如元素a在hover时候可以改变元素b的状态. 效果如本农导航,欢迎采用和建议~ a:hover b{ 执行简单动画效果 } HT ...

  2. url编码 中文在url参数中传递,在请求头,响应头中传递,是如何编码的呢?

    一定要编码成url的吗?还是url自动把接受的汉字编码,请求头响应头到达之后再自动编码成汉字?这样似乎比较合理哦 先把iso8859-1 转换成 utf-8,在mvc中处理,然后响应的时候在转成iso ...

  3. LINUX中的虚拟文件系统结构

    我的博客:www.while0.com 以下以2.6.32版本的内核源码为例: 虚拟文件系统与具体文件系统之间是几组操作函数的对应,包括file_operations,dentry_operation ...

  4. 启动hadoop的命令

    start-all.sh 启动所有的Hadoop守护进程.包括NameNode. Secondary NameNode.DataNode.JobTracker. TaskTrack  stop-all ...

  5. CSS---内外边距

    1.内外边距含义 内边距是div边框内的距离.背景色会覆盖内边距,内边距会使宽高变大. 外边距是div边框外的距离.背景色不会覆盖外边距 内外边距都会撑高父元素,外边距会提高div与div之间的距离 ...

  6. vi编辑器常用操作

    vi的三种模式 1.命令模式 2.编辑模式 3.末行模式(命令模式下,按":"即可进入末行模式) 命令模式到编辑模式:插入命令i,附加命令a,打开命令o,修改命令c,取代命令r,替 ...

  7. Nginx配置虚拟主机

    就是在一台服务器启动多个网站. 如何区分不同的网站: 1.域名不同 2.端口不同 在Nginx的安装目录的conf目录下有个配置文件nginx.conf 1.端口区分: 复制server节点,更改端口 ...

  8. 通过 onclick &equals; &quot&semi;test&lpar;&rpar;&quot&semi;事件定义的事件 &comma; 如何触发&period;

    <div onclick="test()" id="xxx">点击</div> function test() { alert('123 ...

  9. linux环境下运行程序格式错误的问题,bash&colon; &period;&sol;helloworld&colon; cannot execute binary file&colon; Exec format error

    在编译完quecOpen的example helloworld之后,我运行此程序,结果报错,详情如下: ricks@ubuntu:~/share/project/ql-ol-sdk/ql-ol-ext ...

  10. vim常用命令总结&lpar;转&rpar;

    vim常用命令 -------------------------------------------------------------------------------------------- ...