HDU2147 - kiki's game 【巴什博弈】
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!
思路:因为行列分别要走m-1和n-1步,所以要保证至少m和n其中有一个是2的倍数,这样才能保证赢
#include<cstdio>
int main( )
{
int n,m;
while(scanf("%d%d",&n,&m)&&(n!=0||m!=0))
{
if(n%2==0||m%2==0)
printf("Wonderful!\n");
else
printf("What a pity!\n");
}
return 0;
}
HDU2147 - kiki's game 【巴什博弈】的更多相关文章
- HDU - 2147 kiki's game 巴什博弈
思路:以终点(n, m)作为P态,倒推各个坐标的状态,最终得到结论:行数或列数是偶数就能赢,否则输. AC代码 #include <cstdio> #include < ...
- HD1847 Good Luck in CET-4 Everybody!(巴什博弈)
巴什博弈: 一堆物品n个,最多取m个,最少取1个,最后取走的人获胜 分析:只要保证取玩最后剩m+1个,则必定胜利,所以构造m+1,只要n是 m+1的倍数,则先手必败,每次先手取玩,后手可取使得剩下的仍 ...
- HDU2147 kiki's game
/* HDU2147 kiki's game 博弈论 巴什博奕 http://acm.hdu.edu.cn/showproblem.php?pid=2147 题意:在一个n×m的棋盘上,初始棋子放在右 ...
- HDU 1846 Brave Game(巴什博弈)
题目链接: 传送门 Brave Game Time Limit: 1000MS Memory Limit: 65536K 题目描述 各位勇敢者要玩的第一个游戏是什么呢?很简单,它是这样定义的: ...
- hdu 1851 尼姆+巴什博弈
先在每堆中进行巴什博弈,然后尼姆 #include<stdio.h> int main() { int T; int i,n; int ans,m,l; scanf("%d&qu ...
- hdu 4764 Stone (巴什博弈,披着狼皮的羊,小样,以为换了身皮就不认识啦)
今天(2013/9/28)长春站,最后一场网络赛! 3~5分钟后有队伍率先发现伪装了的签到题(博弈) 思路: 与取石头的巴什博弈对比 题目要求第一个人取数字在[1,k]间的某数x,后手取x加[1,k] ...
- Brave Game(裸的巴什博弈)
Brave Game Time Limit: 1000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Total Su ...
- NYOJ-2359: 巴什博弈?
2359: 巴什博弈? 时间限制: 1 Sec 内存限制: 30 MB 提交: 263 解决: 55 [提交][状态][讨论版] 题目描述 有n个石子,有两人轮流从中取石子,最少a个最多b个,谁没 ...
- acm--博弈入门1(巴什博弈1)--(HDU 1846 HDU 2049)
一开始听大佬讲巴什博弈,听成巴士博弈,后来知道了巴什博弈的大名,还知道了博弈不止一种.所谓博弈,就是一场心机的对抗. 好巴什,好巴什......(记得有一个广告语是这么来着) 切入正题: 巴什博弈,问 ...
- BZOJ3729Gty的游戏——阶梯博弈+巴什博弈+非旋转treap(平衡树动态维护dfs序)
题目描述 某一天gty在与他的妹子玩游戏.妹子提出一个游戏,给定一棵有根树,每个节点有一些石子,每次可以将不多于L的石子移动到父节点,询问将某个节点的子树中的石子移动到这个节点先手是否有必胜策略.gt ...
随机推荐
- 混乱的URL编码-C#-JavaScript
文章地址 前后端传值的时候,有时候总是遇到乱码不知道怎么解决,这个还是要分析下各个语言的编码格式 JavaScript中编码有三种方法:escape.encodeURI.encodeURICompon ...
- [bzoj1195][HNOI2006]最短母串_动态规划_状压dp
最短母串 bzoj-1195 HNOI-2006 题目大意:给一个包含n个字符串的字符集,求一个字典序最小的字符串使得字符集中所有的串都是该串的子串. 注释:$1\le n\le 12$,$1\le ...
- POJ 1166 The Clocks (暴搜)
发现对这样的模拟题根本没啥思路了,本来准备用bfs的.可是结果超时了,这是參考别的人代码写的: #include <stdio.h> #include <iostream> # ...
- 【编码格式错误】SyntaxError: Non-UTF-8 code starting with
问题: SyntaxError: Non-UTF-8 code starting with '\xba' in file E:/placement/placement/Placement Test/c ...
- 线程同步、死锁和通信——Java多线程(二)
一.多线程同步 上一篇随笔中,我曾遇到对多线程程序的多次运行结果不一致的情况,这主要是因为没有对这些线程在访问临界资源做必要的控制,而接下来就用线程的同步来解决这个问题. 1.同步代码块 class ...
- [转]详细解读TrueSkill 排名系统
概要 大多数竞技游戏都有一个评价玩家是否完成目标的度量指标,它是游戏的基础.对于包含两个或两个以上玩家(多玩家比赛)的比赛,常涉及到游戏玩家技能的排名方法.游戏鼓励玩家之间相互竞争,玩家不只要赢得单场 ...
- curl ,post,get (原创)
curl get: 1)直接输出 $ch=curl_init(); curl_setopt($ch,CURLOPT_URL,"http://testopen.api.yaolan.com/a ...
- E - Dividing Orange
Problem description One day Ms Swan bought an orange in a shop. The orange consisted of n·k segments ...
- Super超级ERP系统---(1)总体设计
1.概述 随着互联网的发展,尤其是电子商务的发展,信息化系统越来显得越重要.在互联网飞速发展的今天,各种网站,软件系统应用而生,特别是随着近几年电子商务的发展,很多企业慢慢开始做大,管理方面暴露 ...
- JavaWeb详细学习路线图
- Java攻城狮学习路线 - 图转自网络.