HDU 2147 kiki's game(博弈经典题)
题目传送:http://acm.hdu.edu.cn/showproblem.php?pid=2147
Output
设
必胜点(N点):当前位置走过去他要输了哈哈哈
必败点(P点):当前位置没的走了我要输了
所以
能走到必败点的都是必胜点
我们可以确定最后一个必败的情况(即物品数目为0,此题是指点(n,1)的位置,三个方向都找不到空位),然后反着推。可以找到规律:
即: 当m为偶数 或 m为奇数且n为偶数的矩阵,先移硬币的人一定可以找到一个必败点,即先移的人一定最后可以到达(n,1)
当m、n均为奇数时,先移动的只能到达必胜点(即下一个选手取胜)。
#include<cstdio>
#include<iostream>
using namespace std; int main()
{
int n,m;
while(scanf("%d%d",&n,&m)!=EOF&&(n+m))
{
if((n%!=)&&(m%!=))
printf("What a pity!\n");
else
printf("Wonderful!\n");
}
return ;
}
HDU 2147 kiki's game(博弈经典题)的更多相关文章
- HDU 2147 kiki's game(博弈图上找规律)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2147 题目大意:给你一个n*m的棋盘,初始位置为(1,m),两人轮流操作,每次只能向下,左,左下这三个 ...
- HDU 2147 kiki's game(博弈)
kiki's game Time Limit: 1000MS Memory Limit: 10000KB 64bit IO Format: %I64d & %I64u Submit S ...
- hdu 2147 kiki's game, 入门基础博弈
博弈的一些概念: 必败点(P点) : 前一个选手(Previous player)将取胜的位置称为必败点. 必胜点(N点) : 下一个选手(Next player)将取胜的位置称为必胜点. 必败(必胜 ...
- HDU.2147 kiki's game (博弈论 PN分析)
HDU.2147 kiki's game (博弈论 PN分析) 题意分析 简单的PN分析 博弈论快速入门 代码总览 #include <bits/stdc++.h> using names ...
- hdu 2147 kiki's game(巴什博弈)
kiki's game HDU - 2147 题意:一个n*m的表格,起始位置为右上角,目标位置为左下角,甲先开始走,走的规则是可以向左,向下或者向左下(对顶的)走一格.谁先走到目标位置谁就胜利.在甲 ...
- hdu 1045:Fire Net(DFS经典题)
Fire Net Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total Su ...
- HDU 2147 kiki's game(规律,博弈)
kiki's game Time Limit: 5000/1000 MS (Java/Others) Memory Limit: 40000/10000 K (Java/Others)Total ...
- HDU 2147 kiki's game (简单博弈,找规律)
kiki's game Time Limit: 5000/1000 MS (Java/Others) Memory Limit: 40000/1000 K (Java/Others)Total ...
- HDU - 2147 kiki's game 巴什博弈
思路:以终点(n, m)作为P态,倒推各个坐标的状态,最终得到结论:行数或列数是偶数就能赢,否则输. AC代码 #include <cstdio> #include < ...
随机推荐
- 牛客练习赛32 A/B/C
https://ac.nowcoder.com/acm/contest/272/A v<=k时 答案就是k个1 否则贪心的从中间向两边添加1 #include<bits/stdc++.h ...
- Linux 命令查询工具
http://man.linuxde.net/traceroute http://man.linuxde.net/ping http://man.linuxde.net/nslookup 等等
- spring security antMatchers相关内容
一.antMatcher与antMatchers的区别以及使用场景 来源:https://stackoverflow.com/questions/35890540/when-to-use-spring ...
- Python函数式编程,map/reduce,filter和sorted
什么是函数式编程? 与面向对象编程(Object-oriented programming)和过程式编程(Procedural programming)并列的编程范式. 最主要的特征是,函数是第一等公 ...
- io重定向打开关闭 Eclipse中c开发printf无法输出解决办法
if(freopen("e:\\lstm-comparec\\lstm\\lstm\\output.txt","a",stdout)==NULL)fprintf ...
- securecrt远程管理工具连接VM虚拟机
对桥接,net,host_only网络不理解的,请点击:桥接,net,host_only的区别 我这里以net连接为例: 我们使用securecrt实现net的连接,前提是保证虚拟机的ip和虚拟网卡V ...
- POJ 2243 Knight Moves(BFS)
POJ 2243 Knight Moves A friend of you is doing research on the Traveling Knight Problem (TKP) where ...
- laravel中判断当前页面与连接地址是否一致,并添加效果:
- Win10系列:JavaScript小球运动示例
通过前面内容的学习,相信读者已经对开发基于JavaScript的Windows应用商店应用有了一定的了解,本小节通过一个小球运动的示例来介绍如何新建一个JavaScript的Windows应用商店项目 ...
- linux 安装 DenyHosts 防止密码被暴力破解
DenyHosts DenyHosts是Python语言写的一个程序,它会分析sshd的日志文件(/var/log/secure),当发现重 复的攻击时就会记录IP到/etc/hosts.deny文件 ...