天天看点

poj1067

题意:有两堆石子,两人轮流取,每次可以取一堆中的任意个,或两堆中取相同多个。谁先取光所有堆谁赢。问先手能否获胜。

poj1067
poj1067

#include <cstdio>
#include <cmath>
#include <utility>
using namespace std;

int main()
{
    int a, b;
    while (~scanf("%d%d", &a, &b))
    {
        if (a > b)
            swap(a, b);
        int difference = b - a;
        double multiplier = (1 + sqrt(5)) / 2;
        int answer = 1;
        if (a == floor(difference * multiplier))
            answer = 0;
        printf("%d\n", answer);
    }
    return 0;
}      

View Code

上一篇: POJ 1067
下一篇: ac1067