kiki's game

Time Limit: 5000/1000 MS (Java/Others)    Memory Limit: 40000/10000 K (Java/Others)
Total Submission(s): 11452    Accepted Submission(s): 6944

Problem Description
Recently kiki has nothing to do. While she is bored, an idea appears in his mind, she just playes the checkerboard game.The size of the chesserboard is n*m.First of all, a coin is placed in the top right corner(1,m). Each time one people can move the coin into the left, the underneath or the left-underneath blank space.The person who can't make a move will lose the game. kiki plays it with ZZ.The game always starts with kiki. If both play perfectly, who will win the game?
 
Input
Input contains multiple test cases. Each line contains two integer n, m (0<n,m<=2000). The input is terminated when n=0 and m=0.

 
Output
If kiki wins the game printf "Wonderful!", else "What a pity!".
 
Sample Input
5 3
5 4
6 6
0 0
 
Sample Output
What a pity!
Wonderful!
Wonderful!
 
Author
月野兔
 
Source
 
Recommend
威士忌   |   We have carefully selected several similar problems for you:  1846 1847 1848 1849 1517 

已知Nim博弈的必败态条件是:所有集合的异或是0.

这个题目要求有多少种操作,就是有有多少种方式可以由当前状态转移到一个必败态

首先求出异或和,判断当前状态

如果是必胜态,那么尝试着从其中一个集合取数,让这个集合和其他集合的异或和为0.

其他集合的异或和 可用 sum^a[i]来求出 sum^a[i]就等价于a[]中除了a[i]的异或和,因为异或是可逆的操作

然后判断当前的a[i]如果大于sum^a[i],就可以操作这个数字,ans++

#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<sstream>
#include<algorithm>
#include<queue>
#include<deque>
#include<iomanip>
#include<vector>
#include<cmath>
#include<map>
#include<stack>
#include<set>
#include<functional>
#include<fstream>
#include<memory>
#include<list>
#include<string>
using namespace std;
typedef long long LL;
typedef unsigned long long ULL; #define N 100
#define MAXN 20000 + 9
#define INF 1000000009
#define eps 0.00000001
#define sf(a) scanf("%d",&a) int n;
int a[N];
int main()
{
while (sf(n), n)
{
int sum = ;
for (int i = ; i < n; i++)
sf(a[i]), sum ^= a[i];
if (sum == )
cout << << endl;
else
{
int ans = ;
for (int i = ; i < n; i++)
{
if ((sum^a[i]) < a[i])
ans++;
}
cout << ans << endl;
}
}
}

Being a Good Boy in Spring Festival 博弈论 Nim博弈的更多相关文章

  1. HDU 1850 Being a Good Boy in Spring Festival (Nim博弈)

    Being a Good Boy in Spring Festival Time Limit: 1000/1000 MS (Java/Others)    Memory Limit: 32768/32 ...

  2. HDU.1850 being a good boy in spring festival (博弈论 尼姆博弈)

    HDU.1850 Being a Good Boy in Spring Festival (博弈论 尼姆博弈) 题意分析 简单的nim 博弈 博弈论快速入门 代码总览 #include <bit ...

  3. hdu 1850 Being a Good Boy in Spring Festival 博弈论

    求可行的方案数!! 代码如下: #include<stdio.h> ]; int main(){ int n,m; while(scanf("%d",&n)&a ...

  4. Being a Good Boy in Spring Festival 尼姆博弈

    Time Limit:1000MS     Memory Limit:32768KB     64bit IO Format:%I64d & %I64u Submit Status Descr ...

  5. HDU1850 Being a Good Boy in Spring Festival

    /* HDU1850 Being a Good Boy in Spring Festival http://acm.hdu.edu.cn/showproblem.php?pid=1850 博弈论 尼姆 ...

  6. HDU1850 Being a Good Boy in Spring Festival(博弈)

    Being a Good Boy in Spring Festival Time Limit: 1000MS   Memory Limit: 32768KB   64bit IO Format: %I ...

  7. hdu 1850 Being a Good Boy in Spring Festival(Nimm Game)

    题意:Nimm Game 思路:Nimm Game #include<iostream> #include<stdio.h> using namespace std; int ...

  8. Being a Good Boy in Spring Festival(尼姆博弈)

    Being a Good Boy in Spring Festival Time Limit: 1000/1000 MS (Java/Others) Memory Limit: 32768/32768 ...

  9. Being a Good Boy in Spring Festival(杭电1850)(尼姆博弈)

    Being a Good Boy in Spring Festival Time Limit: 1000/1000 MS (Java/Others)    Memory Limit: 32768/32 ...

随机推荐

  1. Laravel5中防止XSS跨站攻击的方法

    本文实例讲述了Laravel5中防止XSS跨站攻击的方法.分享给大家供大家参考,具体如下: Laravel 5本身没有这个能力来防止xss跨站攻击了,但是这它可以使用Purifier 扩展包集成 HT ...

  2. js点击修改按钮后修改

    <button id="click">改变内容</button> <div id="t">要改变的内容</div> ...

  3. asp.net网站接入QQ登录

    这两天在做网站第三方登录,总结一下QQ登录吧,支付宝就不用了(下载dome把ID什么的换一换就基本可以了.),本文主要说的是代码的实现方式,逻辑部分主要还是根据帮助文档来的.不懂的同学可以先看看文档. ...

  4. shutil模块 + shelve模块 二合一版

    其他的看我前面的博客 import shutil # 将文件内容拷贝到另一个文件with open('old.xml','r') as read_f,open('new.xml', 'w') as w ...

  5. 《基于Node.js实现简易聊天室系列之引言》

    简述:这个聊天室是基于Node.js实现的,完成了基本的实时通信功能.在此之前,对node.js和mongodb一无所知,但是通过翻阅博客,自己动手基本达到了预期的效果.技术,不应该是闭门造车,而是学 ...

  6. Win10 1803更新UWP无法安装的解决办法|错误代码0x80073D0D

    升级Win10 1803后,出现了之前安装的UWP.应用无法更新,再此安装失败的现象. 应用商店错误代码为:0x80073D0D,尝试卸载重装商店,清除应用缓存也无法解决. 最终解决办法: 下载Eve ...

  7. 通过SSDT HOOK实现进程保护和进程隐藏

    ---恢复内容开始--- 首先,我要说一件很重要的事,本人文采不好,如果哪里说的尴尬了,那你就尴尬着听吧...... SSDT HOOK最初貌似源于Rookit,但是Rookit之前有没有其他病毒使用 ...

  8. 迅为7寸工业平板电脑|人机界面|工业触摸屏|工控机|HMI|工业显示器

    型号:iTOP-HMI070-C 7寸工业平板电脑特点: 1.iTOP-HMI070-C(CAN) 7寸工业触摸屏,CAN总线型触摸屏,配有2组独立的串口和一路CAN总线口: 2.串口都支持各种PLC ...

  9. Linux之基础命令——打包压缩

    tar(备份与打包) linux中tar命令相当于win下的多个文件压缩成一个压缩文件. -c:创建新的备份文件 -x:还原压缩的备份文件 -f:需要备份归档的文件名 -j:使用bzip2解压缩 -z ...

  10. sql server update+select(子查询修改)20190304

    if OBJECT_ID('tempdb..##t2') is not null drop table ##t2;create table ##t2( a int, b int, c datetime ...