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 ...
随机推荐
- 0208如何利用federated配置远程的数据库和本地数据相互交互
-- 第一步修改本地数据库的配置文件,让其支持federated存储引擎,在[mysqld]配置文件下面增加federated[注意不能写成大写]-- federated -- 第二步创建一个数据库, ...
- 洛谷 P1463 [SDOI2005]反素数ant
P1463 [SDOI2005]反素数ant 题目描述 对于任何正整数x,其约数的个数记作g(x).例如g(1)=1.g(6)=4. 如果某个正整数x满足:g(x)>g(i) 0<i< ...
- sync_binlog=1
MySQL提供一个sync_binlog参数来控制数据库的binlog刷到磁盘上去. sync_binlog=0,表示MySQL不控制binlog的刷新,由文件系统自己控制它的缓存的刷新.这时候的性能 ...
- ruby for in 循环中改变i的值无效
ruby for in 循环中改变i的值无效 for j in 1..5 puts "#{j}hehe" j = j + 2 #break end 在循环中,使用j = j + 2 ...
- HDU 3579 Hello Kiki 中国剩余定理(合并方程
题意: 给定方程 res % 14 = 5 res % 57 = 56 求res 中国剩余定理裸题 #include<stdio.h> #include<string.h> # ...
- Android - 找到当前类的Context
找到当前类的Context 本文地址: http://blog.csdn.net/caroline_wendy 假设是在onContinueCreate或onCreate中, 直接使用this, 就代 ...
- maven创建web报错failure to transfer org.codehaus.plexus
failure to transfer org.codehaus.plexus:plexus:pom:2.0.5 from http:// repo.maven.apache.org/maven2 w ...
- Codeforces Beta Round #95 (Div. 2) D. Subway 边双联通+spfa
D. Subway A subway scheme, classic for all Berland cities is represented by a set of n stations co ...
- 控制台中使用SetTimer的提醒
SetTimer是设置定时器,每隔一段时间执行一个操作,原型如下 UINT_PTR SetTimer( HWND hWnd, // 窗口句柄 UINT_PTR nIDEvent, // 定时器ID,多 ...
- luogu4011 孤岛营救问题 分层图
关键词:分层图 状态压缩 最短路径 分层图:现在要求从起点到终点的最优路线,但受到手里拿着哪些钥匙的影响,最优路线不单纯了.因此,决定一个节点.一条边的存在的数中应当增加一个手中拿有钥匙的状态.这样就 ...