kiki's game

Time Limit: 5000/1000 MS (Java/Others)    Memory Limit: 40000/10000 K (Java/Others)
Total Submission(s): 12851    Accepted Submission(s): 7823

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
 
  观察发现可以打表预处理一下整个棋盘,从左下角到右上角处理,每个位置只有1/0两种状态。当所有子状态全都是1的时候为0,否则为1.
 #include<bits/stdc++.h>
using namespace std;
bool f[][];
int fx[][]={,-,,,,-};
int main(){
int n,m,i,j,k;
n=;
m=;
f[n][]=;
for(i=n;i>=;--i){
for(j=;j<=m;++j){
if(i==n&&j==) continue;
int tot1=,tot2=;
for(k=;k<;++k){
int dx=i+fx[k][];
int dy=j+fx[k][];
/*if(i==5&&j==3)
cout<<dx<<" -"<<dy<<endl;*/
if(dx>=&&dx<=n&&dy>=&&dy<=m){
tot1++;
if(f[dx][dy]) tot2++;
}
} if(tot1==tot2) f[i][j]=;
else f[i][j]=;
}
}
while(cin>>n>>m&&(n&&m))
f[-n+][m]?puts("Wonderful!"):puts("What a pity!");
return ;
}

再仔细观察发现......

#include<stdio.h>
int main()
{
int n,m;
while(~scanf("%d%d",&n,&m)&&n&&m)
{
if(n%&&m%)
printf("What a pity!\n");
else
printf("Wonderful!\n");
}
return ;
}

hdu-2147-博弈的更多相关文章

  1. HDU 2147 (博弈) kiki's game

    无奈英语不好又被坑,看到棋子能左移下移左下移,想当然地以为是Wythoff博弈了,=u= 题的意思是说每次只能选一个方向移动一步,所以找找规律就是横纵坐标为奇数的时候是必败状态. 从http://ww ...

  2. HDU - 2147 博弈 P/N分析

    结论题,很显然和奇偶有关 PS.尝试用dfs写出PN表写崩了 #include<iostream> #include<algorithm> #include<cstdio ...

  3. hdu 2147 kiki&#39;s game, 入门基础博弈

    博弈的一些概念: 必败点(P点) : 前一个选手(Previous player)将取胜的位置称为必败点. 必胜点(N点) : 下一个选手(Next player)将取胜的位置称为必胜点. 必败(必胜 ...

  4. hdu 2147 kiki's game(巴什博弈)

    kiki's game HDU - 2147 题意:一个n*m的表格,起始位置为右上角,目标位置为左下角,甲先开始走,走的规则是可以向左,向下或者向左下(对顶的)走一格.谁先走到目标位置谁就胜利.在甲 ...

  5. HDU.2147 kiki's game (博弈论 PN分析)

    HDU.2147 kiki's game (博弈论 PN分析) 题意分析 简单的PN分析 博弈论快速入门 代码总览 #include <bits/stdc++.h> using names ...

  6. S-Nim HDU 1536 博弈 sg函数

    S-Nim HDU 1536 博弈 sg函数 题意 首先输入K,表示一个集合的大小,之后输入集合,表示对于这对石子只能去这个集合中的元素的个数,之后输入 一个m表示接下来对于这个集合要进行m次询问,之 ...

  7. HDU 2147 kiki's game(博弈经典题)

    题目传送:http://acm.hdu.edu.cn/showproblem.php?pid=2147 Problem Description Recently kiki has nothing to ...

  8. HDU 2147 kiki's game(规律,博弈)

    kiki's game Time Limit: 5000/1000 MS (Java/Others)    Memory Limit: 40000/10000 K (Java/Others)Total ...

  9. (博弈 sg入门)kiki's game -- hdu -- 2147

    链接: http://acm.hdu.edu.cn/showproblem.php?pid=2147 题意: 在一个n*m的棋盘上,从  (1,m),即右上角开始向左下角走. 下棋者只能往左边(lef ...

  10. HDU 2147 kiki's game(博弈图上找规律)

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2147 题目大意:给你一个n*m的棋盘,初始位置为(1,m),两人轮流操作,每次只能向下,左,左下这三个 ...

随机推荐

  1. P2322 [HNOI2006]最短母串问题

    P2322 [HNOI2006]最短母串问题 AC自动机+bfs 题目要求:在AC自动机建的Trie图上找到一条最短链,包含所有带结尾标记的点 因为n<12,所以我们可以用二进制保存状态:某个带 ...

  2. RabbitMQ详解(一)------简介与安装(Docker)

    RABBITMQ详解(一)------简介与安装(DOCKER) 刚刚进入实习,在学习过程中没有接触过MQ,RabbitMQ 这个消息中间件,正好公司最近的项目中有用到,学习了解一下. 首先什么是MQ ...

  3. python脚本监控获取当前Linux操作系统[内存]/[cpu]/[硬盘]/[登录用户]

    此脚本应用在linux, 前提是需要有python和python的psutil模块 脚本 #!/usr/bin/env python # coding=utf-8 import sys import ...

  4. 【前端】javascript+jquery实现手风琴式的滚动banner或产品展示图

    实现效果 实现步骤 // 鼠标放入到li中该盒子变宽,其他盒子变窄,鼠标移开大盒子,恢复原样 // 实现步骤 // 1. 给li添加背景 // 2. 绑定onmouseover事件,鼠标放入到li中, ...

  5. sql:临时表和表变量

    在SQL Server的性能调优中,有一个不可比拟的问题:那就是如何在一段需要长时间的代码或被频繁调用的代码中处理临时数据集,表变量和临时表是两种选择. 临时表: 临时对象都以#或##为前缀,临时表是 ...

  6. 蚂蚁感冒|2014年蓝桥杯B组题解析第八题-fishers

    蚂蚁感冒 长100厘米的细长直杆子上有n只蚂蚁.它们的头有的朝左,有的朝右. 每只蚂蚁都只能沿着杆子向前爬,速度是1厘米/秒. 当两只蚂蚁碰面时,它们会同时掉头往相反的方向爬行. 这些蚂蚁中,有1只蚂 ...

  7. POJ 3480 John(SJ定理博弈)题解

    题意:n堆石头,拿走最后一块的输 思路:SJ定理:先手必胜当且仅当:(1)游戏的SG函数不为0且游戏中某个单一游戏的SG函数大于1:(2)游戏的SG函数为0且游戏中没有单一游戏的SG函数大于1. 参考 ...

  8. [Redis] - 高并发下Redis缓存穿透解决

    高并发情况下,可能都要访问数据库,因为同时访问的方法,这时需要加入同步锁,当其中一个缓存获取后,其它的就要通过缓存获取数据. 方法一: 在方法上加上同步锁 synchronized //加同步锁,解决 ...

  9. [loss]Triphard loss优雅的写法

    之前一直自己手写各种triphard,triplet损失函数, 写的比较暴力,然后今天一个学长给我在github上看了一个别人的triphard的写法,一开始没看懂,用的pytorch函数没怎么见过, ...

  10. 发现 一个 http 压测库

    代码库:https://github.com/wg/wrk 安装 https://github.com/wg/wrk