POJ1067之威佐夫博弈

来源:互联网 发布:js bytearray 遍历 编辑:程序博客网 时间:2024/06/05 06:04

题目传送门:http://poj.org/problem?id=1067

主要求出当前是不是奇异局势就好啦~

要用到黄金分割~

代码:

#include <cstdio>#include <cstring>#include <iostream>#include <algorithm>#include <cmath>const int MAXN=10000;using namespace std;int main (void){    long long a,b;    double shu=(1 + sqrt(5.0))/2.0;    while(~scanf("%lld %lld",&a,&b))    {        if (a > b)            swap(a, b);        long long k = b - a;        if (a == (long long)(k * shu))        {            printf("0\n");            continue;        }        else        {            printf("1\n");            continue;        }    }    return 0;}
0 0
原创粉丝点击