此题用到的概念: 【定义1】:若一堆中仅有一个石子,则被称为孤单堆。若大于1个,则称为充裕堆。 【定义2】:T态中,若充裕堆的堆数大于等于2,则称为完全利他态,用T2表示;若充裕堆的堆数等于0,则称为部分利他态。用T0表示。         孤单堆的根数异或智慧影响二进制的最后以为,但充裕堆会影响高位(非最后一位)。一个充裕堆,高位必有一位不为0,则所有根数异或不为0。故不会是T态。 【定理1】:S0态,即仅有奇数个孤单堆,必败。T0态必胜。 证明:S0态,其实就是每次只能取一根。每次第奇数根都由自己取,第偶数根都由对方取,所以最后一根必由自己取。所以必败。同理:T0态必胜。 【定理2】:S1态,只要方法正确,必胜。 证明:若此时孤单堆堆数为奇数,把充裕堆取完;否则,取成一根。这样,就变成奇数个孤单堆,由对方取。由定理1,对方必输,己必胜。 【定理3】:S2态不可转一次变为T0态。 证明:充裕堆数不可能一次由2变为0。 【定理4】:S2态可一次转变为T2态。 证明:因为对于任何一个S态,总能从一堆中取出若干个使之成为T态。又因为S1态,只要方法正确,必胜。S2态不可转一次变为T0态,所以转变的T态为T2态。 【定理5】:T2态,只能转变为S2态或S1态。 证明:因为T态,取任何一堆的若干根都将成为S态。由于充裕堆不可能一次由2变为0,所以此时的S态不可能为S0态。得证。 【定理6】:S2态,只要方法正确,必胜。 证明:方法如下: S2态,就把它变为T2态。(定理4); 对方只能T2转变为S2态或S1态(定理5)。 若转变为S2,则转向①。 若转变为S1,这时己必胜(定理1)。 【定理7】:T2态必输。 证明:同定理6. 综上所述:必输态有:T2、S0;必胜态有:S2、S1、T0。

Be the Winner

Time Limit : 2000/1000ms (Java/Other)   Memory Limit : 32768/32768K (Java/Other)
Total Submission(s) : 2   Accepted Submission(s) : 2
Problem Description
Let's consider m apples divided into n groups. Each group contains no more than 100 apples, arranged in a line. You can take any number of consecutive apples at one time. For example "@@@" can be turned into "@@" or "@" or "@ @"(two piles). two people get apples one after another and the one who takes the last is the loser. Fra wants to know in which situations he can win by playing strategies (that is, no matter what action the rival takes, fra will win).
 
Input
You will be given several cases. Each test case begins with a single number n (1 <= n <= 100), followed by a line with n numbers, the number of apples in each pile. There is a blank line between cases.
 
Output
If a winning strategies can be found, print a single line with "Yes", otherwise print "No".
 
Sample Input
2 2 2 1 3
 
Sample Output
No Yes
 
Source
ECJTU 2008 Autumn Contest
思路:
   这题与以往的博弈题的胜负条件不同,谁先走完最后一步谁输,但他也是一类Nim游戏,即为anti-nim游戏。 首先给出结论:先手胜当且仅当 ①所有堆石子数都为1且游戏的SG值为0(即有偶数个孤单堆-每堆只有1个石子数);②存在某堆石子数大于1且游戏的SG值不为0. 证明: 若所有堆都为1且SG值为0,则共有偶数堆石子,故先手胜。 i)只有一堆石子数大于1时,我们总可以对该石子操作,使操作后堆数为奇数且所有堆的石子数均为1; ii)有超过一堆的石子数1时,先手将SG值变为0即可,且总还存在某堆石子数大于1 因为先手胜。

 代码:尼姆博弈变形(anti-nimu)

 #include<iostream>
using namespace std;
int main()
{
int n,m,i,x;
bool flag;
while(scanf("%d",&n)!=EOF)
{
flag=false;
for(x=i=;i<n;i++)
{
scanf("%d",&m);
x^=m;
if(m>) flag=true; //孤单堆
}
if(!flag) printf(n&==?"No\n":"Yes\n");
else printf(x==?"No\n":"Yes\n");
}
return ;
}

HDUOJ-----Be the Winner的更多相关文章

  1. HDU 5754 Life Winner Bo 组合博弈

    Life Winner Bo Problem Description   Bo is a "Life Winner".He likes playing chessboard gam ...

  2. HDU 2509 Be the Winner nim博弈变形

    Be the Winner Problem Description   Let's consider m apples divided into n groups. Each group contai ...

  3. hduoj 1455 && uva 243 E - Sticks

    http://acm.hdu.edu.cn/showproblem.php?pid=1455 http://uva.onlinejudge.org/index.php?option=com_onlin ...

  4. HDU5754 Life Winner Bo(博弈)

    题目 Source http://acm.hdu.edu.cn/showproblem.php?pid=5754 Description Bo is a "Life Winner" ...

  5. Codeforces Beta Round #2 A. Winner

    A. Winner time limit per test 1 second memory limit per test 64 megabytes input standard input outpu ...

  6. HDU2509 Be the Winner

    Be the Winner Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Tot ...

  7. Recruit Coupon Purchase Winner's Interview: 2nd place, Halla Yang

    Recruit Coupon Purchase Winner's Interview: 2nd place, Halla Yang Recruit Ponpare is Japan's leading ...

  8. winner tree 胜者树

    在树形选择排序中,利用锦标赛思想建立的树称为胜者树. 1.每个非终端节点存储的是左右孩子节点中的优胜者. 2.通过减少比较次数,提高效率. 3.胜者树就是一颗特殊的线段树. 一.构建树 Procedu ...

  9. hduoj 4712 Hamming Distance 2013 ACM/ICPC Asia Regional Online —— Warmup

    http://acm.hdu.edu.cn/showproblem.php?pid=4712 Hamming Distance Time Limit: 6000/3000 MS (Java/Other ...

  10. hduoj 4706 Herding 2013 ACM/ICPC Asia Regional Online —— Warmup

    hduoj 4706 Children's Day 2013 ACM/ICPC Asia Regional Online —— Warmup Herding Time Limit: 2000/1000 ...

随机推荐

  1. Android之Android软键盘的隐藏显示研究

    转自:http://blog.csdn.net/lilu_leo/article/details/6587578 看了很多这类型的文章,这篇文章最有价值,解决了我的烦恼,必须转. Android是一个 ...

  2. UVC调试

    USB video class(又称为USB video device class or UVC)就是USB device class视频产品在不需要安装任何的驱动程序下即插即用,包括摄像头.数字摄影 ...

  3. [MAC OS] NSOpenPanel 使用

    Mac OS开启沙盒之后,文件的保存会涉及到一个权限问题.如下图,在Capabilities中,可以勾选的权限一共有5种. User Selected File 必须勾选,否则 NSOpenPanel ...

  4. 混沌数学之Lorenz(洛伦茨)吸引子

    洛伦茨吸引子是洛伦茨振子(Lorenz oscillator)的长期行为对应的分形结构,以爱德华·诺顿·洛伦茨的姓氏命名. 洛伦茨振子是能产生混沌流的三维动力系统,是一种吸引子,以其双纽线形状而著称. ...

  5. 如何查看ETW Trace?

    三种方法: LogParser Tractrpt - C:\Windows\System32 SvcTraceViewer.exe   后面的链接中有使用的详细步骤.   参考资料 ========= ...

  6. 检测 USB 设备拨插的 C# 类库:USBClassLibrary

    这是采用C#开发的一个USB库,使您可以管理USB设备的连接和分离事件,探测自己的设备.可以运行在Windows XP和Windows7 64位系统下. 01 private void USBPort ...

  7. IDA远程调试so库JNI_Onload函数

    JNI_OnLoad函数大概功能就是在程序加载so的时候,会执行JNI_OnLoad函数,做一系列的准备工作.很多时候,程序猿们会将一些重要信息放在此函数中,而不是通过某种事件来重复触发.包括说将反调 ...

  8. SpringBoot四大神器之Starter

    SpringBoot的starter主要用来简化依赖用的.本文主要分两部分,一部分是列出一些starter的依赖,另一部分是教你自己写一个starter. 部分starters的依赖 Starter( ...

  9. [Node.js] Load balancing a Http server

    Let's see how to do load balancing in Node.js. Before we start with the solution, you can do a test ...

  10. 【线段树】HDU 3397 Sequence operation 区间合并

    操作 Change operations: 0 a b change all characters into '0's in [a , b] 1 a b change all characters i ...