HDU 1527 - 取石子游戏

裸威佐夫博奕。证明见:http://blog.csdn.net/acm_cxlove/article/details/7854530

代码如下:

#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
using namespace std;
double eps = 1e-9;
int main()
{
#ifdef test
    freopen("input.txt", "r", stdin);
#endif
    int a, b;
    while(scanf("%d%d", &a, &b) != EOF)
    {
        if(a > b)
            swap(a, b);
        double k = b - a;
        int ans = k * (sqrt(5.0) + 1) / 2.0;
        if(ans == a)
            puts("0");
        else
            puts("1");
    }
    return 0;
}


猜你喜欢

转载自blog.csdn.net/GooMaple/article/details/8884357
今日推荐