码迷,mamicode.com
首页 > 其他好文 > 详细

[原博客] POJ 2484 A Funny Game

时间:2014-09-08 00:56:56      阅读:193      评论:0      收藏:0      [点我收藏+]

标签:style   blog   http   color   os   io   ar   strong   art   

题目链接
题意:有n个硬币排成一圈,两个人轮流操作,每次可以取走一个或者相邻的连个硬币(只算最开始相邻的,取之后才相邻的不算),问先手必胜还是必败。


这个题可以证明若n>=3,则先手必败。
对称博弈
n>=3,先手第一次必然把这个环拆成一个链,然后无论这条链长度的奇偶,后手总是可以把这条链分成两条相等的链,于是先手在一条链上做什么,后手就可以做什么。知道先手无法操作,后手胜。

bubuko.com,布布扣
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
 
//by zrt
//problem:
using namespace std;
typedef long long LL;
const int inf(0x3f3f3f3f);
const double eps(1e-9);
int n;
int main(){
    #ifdef LOCAL
    freopen("in.txt","r",stdin);
    freopen("out.txt","w",stdout);
    #endif
    while(scanf("%d",&n),n){
        if(n>=3){
            puts("Bob");
        }else puts("Alice");
    }
    return 0;
}
View Code

 

[原博客] POJ 2484 A Funny Game

标签:style   blog   http   color   os   io   ar   strong   art   

原文地址:http://www.cnblogs.com/zrts/p/3960976.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!