hdu_2147_kiki's game
来源:互联网 发布:京东大数据平台架构 编辑:程序博客网 时间:2024/05/16 06:42
kiki's game
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!#include <iostream>#include <cstdio>#include <cstring>using namespace std;//int win[2000][2000];打印PN表,找规律/*bool sg(int n, int m){if (win[n][m] != -1)return win[n][m];if (!sg(n - 1, m) || !sg(n - 1, m - 1) || !sg(n, m - 1)){win[n][m] = 1;return 1;}win[n][m] = 0;return 0;}*/int main(){int n, m;/*memset(win, -1, sizeof(win));for (int i = 1; i < 2000; i++){if (i % 2 == 0){win[i][1] = 1;win[1][i] = 1; }else {win[i][1] = 0;win[1][i] = 0;}}win[1][1] = 0;for (int i = 1; i < 100; i++){for (int j = 1; j < 100; j++){if (win[i][j] == -1)sg(i, j);printf("%d %d %d\n", i, j, win[i][j]);getchar();}}*/while (scanf("%d%d", &n, &m) != EOF && n +m){if (n % 2 == 0 || m % 2 == 0)printf("Wonderful!\n");else printf("What a pity!\n");}return 0;}
0 0
- hdu_2147_kiki's game
- hdu_2147_kiki's game(博弈)
- 1889. Max’s game
- 【poj2348】Euclid's Game
- 10905 - Children's Game
- kiki's game
- 10905 - Children's Game
- uva_10404_Bachet's Game
- uva_10404-Bachet's Game
- HDU2147-kiki's game
- 10905 - Children's Game
- uva10905 - Children's Game
- 10404 - Bachet's Game
- poj2348 - Euclid's Game
- HDU1525 Euclid's Game
- uva_10905_Children's Game( 貪心好題 )
- UVaOJ10905 - Children's Game
- let‘s play game!
- NULL空记录引起的查询错误
- 三、集合数据类型Collection Data Types
- java.sql.SQLException: ORA-00907: 缺失右括号
- XML解析:DOM、SAX、XMLParser
- Array和Arrays类应用
- hdu_2147_kiki's game
- 利用红外线接收器触发中断信号
- Service 'china' of type 'MapServer' does not exist or is inaccessible
- 旋转数组的最小数字
- 动态规划
- c++日历改进版
- OpenGL: 图形试验
- 链接矩阵快速幂(zoj3497)
- 用pl/sql导出、导入用户的表、存储