题目链接 http://acm.hdu.edu.cn/showproblem.php?pid=1527
以前在网上看过一点bash博弈和尼姆博弈,刚开始看到这道题的时候,以为是用什么技巧解或者转化成尼姆,想了半天想不到什么好方法,才想起来以前看博弈的时候有个威佐夫博弈留着没看,就觉得可能考的是没学的那个博弈,百度搜了下,发现这题就是一裸的威佐夫博弈。。
威佐夫博弈讲解链接 https://blog.csdn.net/ac_gibson/article/details/41624623
#include <cstdio> #include <cmath> #include <iostream> #include <cstring> using namespace std; int main(){ int ak,bk; while(scanf("%d%d",&ak,&bk) != EOF){ if(ak > bk){ //交换 int t = ak; ak = bk; bk = t; } int k = bk - ak; int t = (int)((sqrt(5.0)+1) / 2 * k); //这里写成sqrt(5)在vjudge里会CE if(t == ak){ printf("0\n"); }else{ printf("1\n"); } } return 0; }