POJ 1067 取石子游戏

原题链接:点击此处

思路:

这道题就是博弈论的运用,有兴趣的可以看看: 组合博弈 -- 三大基本博弈

源代码:

#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <cmath>
using namespace std;

int main()
{

    int a,b,k,ak;
    while(scanf("%d %d",&a,&b)!=EOF)
    {
        k=abs(a-b);
        a=a<b?a:b;
        ak=(int)(k*(1.0+sqrt(5.0))/2);
        printf("%d\n",ak==a?0:1);
    }
    return 0;
}
View Code

 

posted @ 2016-08-06 15:48  君子酱  阅读(122)  评论(0编辑  收藏  举报