取石子游戏

来源:互联网 发布:天启秒杀软件 编辑:程序博客网 时间:2024/06/05 10:07

题目链接:http://poj.org/problem?id=1067

这是一道威佐夫博奕(Wythoff Game),具体分析参考http://www.cnblogs.com/celia01/archive/2011/11/15/2250171.html

我自己的代码如下:

#include<cstdio>#include<cmath>#include<algorithm>using namespace std;/************************************/void tt(int x, int y){    int t, d;    if( x>y )    {        t=x;                                     /*判断是否为奇异局势*/        x=y;                                           y=t;    }    d=(double)((y-x)*(sqrt(5.0)+1)/2);    if(d==x)  printf("0\n");    else      printf("1\n");}/*************************************/int main(){    int a, b;    while(~scanf("%d%d", &a, &b))    {        tt(a, b);                             /*调用函数*/    }    return 0;}


0 0
原创粉丝点击