HDU 2147 kiki's game【巴什博奕】
来源:互联网 发布:嵌入式linux系统开发 编辑:程序博客网 时间:2024/06/16 23:53
kiki's game
Time Limit: 5000/1000 MS (Java/Others) Memory Limit: 40000/10000 K (Java/Others)Total Submission(s): 10883 Accepted Submission(s): 6594
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 35 46 60 0
Sample Output
What a pity!Wonderful!Wonderful!
Author
月野兔
Source
HDU 2007-11 Programming Contest
Recommend
威士忌
P→必胜点
N→必败
最左下角的点是P,然后往前推,一步步的去画表格就可以了。
P
由于1,6和2,7位置只能向1,7位置移动,所以1,6与2,7为N。
N
PN
同理,第1列和第7行就可以填充完毕。
P
N
P
N
P
N
PNPNPNP再反观2,6位置,作为2,6位置上的人,想赢得这场比赛,所以肯定会向1,7移动,因此2,6也是N
N
P
N
P
N
PNPNPNP再反观2,6位置,作为2,6位置上的人,想赢得这场比赛,所以肯定会向1,7移动,因此2,6也是N
P
N
P
N
P
NN
PNPNPNP每个位置上,都会向赢比赛的趋向走,所以剩余各个点的P、N都可以填充完毕
N
P
N
P
NN
PNPNPNP每个位置上,都会向赢比赛的趋向走,所以剩余各个点的P、N都可以填充完毕
PNPNPNPNNNNNNNPNPNPNPNNNNNNNPNPNPNPNNNNNNNPNPNPNP
此图填完,可以找到规律:
此图填完,可以找到规律:
只有在行列数均为奇数时,为P,其他情况均为N。
#include<iostream>#include<cstdio>#include<cstring>#include<string>#include<cmath>#include<queue>#include<stack>#include<vector>#include<map>#include<set>#include<algorithm>using namespace std;#define ll long long#define ms(a,b) memset(a,b,sizeof(a))const int M=1e5+10;const int inf=0x3f3f3f3f;const int mod=1e9+7;int i,j,k,n,m;int h,r,t;double g=10.0;double y[M];int main(){ while(~scanf("%d%d",&n,&m)){ if(n==0&&m==0)break; if(n%2&&m%2)printf("What a pity!\n"); else printf("Wonderful!\n"); } return 0;}
阅读全文
0 0
- 巴什博奕 hdu oj 2147 kiki's game
- HDU 2147 kiki's game【巴什博奕】
- hdu 2147 kiki's game
- HDU-2147:kiki's game
- hdu 2147 kiki's game
- HDU 2147 - kiki's game
- hdu 2147 kiki's game
- HDU 2147 kiki's game
- HDU 2147kiki's game
- hdu 2147 kiki's game
- HDU 2147 kiki's game
- HDU 2147 kiki's game
- hdu 2147 kiki's game
- HDU 2147 kiki's game
- HDU 2147 kiki's game
- HDU 2147 kiki's game
- hdu 2147 kiki's game
- 【HDU 2147 kiki's game】
- C# MediaPlayer的详细用法
- mysql排序让空值NULL排在数字后边
- mybatis做like模糊查询的常见三种方法
- 拿代码量算绩效考核?别毁了程序员
- 正则表达式详解
- HDU 2147 kiki's game【巴什博奕】
- Payments:这个产品才是真正意义上的第一个VR支付产品
- tomcat报错 ApplicationEventMulticaster not initialized
- 一到十二月英语简写
- spring注解:常用易懂
- NFS server的配置与使用
- java面试(2)
- mysql数据库迁移手动迁移
- TensorFlow