hdu 2147 kiki's game
39 HDU Game
2023-09-11 14:15:29 时间
kiki's game
Time Limit: 5000/1000 MS (Java/Others) Memory Limit: 40000/1000 K (Java/Others)
Total Submission(s): 6476 Accepted Submission(s): 3845
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
解题:利用P/N态,作图
P点:就是P个石子的时候,对方拿可以赢(自己输的)
N点:就是N个石子的时候,自己拿可以赢
现在关于P,N的求解有三个规则
(1):最终态都是P
(2):按照游戏规则,到达当前态的前态都是N的话,当前态是P
(3):按照游戏规则,到达当前态的前态至少有一个P的话,当前态是N
以上内容摘自http://blog.163.com/gditacmfeng@yeah/blog/static/13702062420100160358818/
1 #include <iostream> 2 #include <cstdio> 3 #include <cstring> 4 #include <cmath> 5 #include <algorithm> 6 #include <climits> 7 #include <vector> 8 #include <queue> 9 #include <cstdlib> 10 #include <string> 11 #include <set> 12 #define LL long long 13 #define INF 0x3f3f3f3f 14 using namespace std; 15 16 int main(){ 17 int n,m; 18 while(scanf("%d%d",&n,&m),n+m){ 19 n %= 2; 20 m %= 2; 21 if(n && m) puts("What a pity!"); 22 else puts("Wonderful!"); 23 } 24 return 0; 25 }
相关文章
- kubelet拉取pause镜像报错pull access denied for 172.20.59.190:81/kubernetes/pause-amd64, repository does not exist or may require 'docker login': denied
- Why isn't INFORMATION_SCHEMA not displayed in the MySQL Workbench UI by default?
- What's the difference between Html.Label, Html.LabelFor and Html.LabelForModel
- Validation failed for one or more entities. See 'EntityValidationErrors' property for more details
- Mac M1 clang: error: the clang compiler does not support 'faltivec'问题解决
- SQLite 解决:Could not load file or assembly 'System.Data.SQLite ... 试图加载格式不正确的程序/or one of its dependencies. 找不到指定的模块。
- HDU 3966 Aragorn's Story
- HDU 5136 Yue Fei's Battle
- 2015 Multi-University Training Contest 7 hdu 5371 Hotaru's problem
- 2015 Multi-University Training Contest 5 hdu 5348 MZL's endless loop
- Idea运行报错Error running 'Application': Command line is too long的解决方法
- HDU 4430 Yukari's Birthday (二分)
- HDU 4114 Disney's FastPass (状压DP)
- HDU 4349 Xiao Ming's Hope (Lucas)
- HDU 4352 XHXJ's LIS (数位DP+LIS+状态压缩)
- SAP S4HANA 账户组的配置里'Int.Std.Grping'选项没勾选导致ABAP程序报错
- flink-sql-gateway:Caused by: org.apache.flink.table.api.NoMatchingTableFactoryException: Could not find a suitable table factory for 'org.apache.flink.table.factories.CatalogFactory' in the classpath.
- "不能将值 NULL 插入列 'ID',表 列不允许有 Null 值."
- 安装 R 包报错 clang: error: unsupported option '-fopenmp' 的解决方法
- 【vue踩坑记录】3、“Error in render: "TypeError: Cannot read property '0' of undefined"”渲染错误问题
- 关于<a href='javascript:function()'>
- Solve Error: 'has incomplete type', foward declaration of 'class x'
- 甲骨文宣布因 '主要增强功能'延迟发布Java EE 8