题意:有两堆石子,两人轮流取,每次可以取一堆中的任意个,或两堆中取相同多个。谁先取光所有堆谁赢。问先手能否获胜。
![](https://img.laitimes.com/img/9ZDMuAjOiMmIsIjOiQnIsISPrdEZwZ1Rh5WNXp1bwNjW1ZUba9VZwlHdsATOfd3bkFGazxCMx8VesATMfhHLlN3XnxCMwEzX0xiRGZkRGZ0Xy9GbvNGLpZTY1EmMZVDUSFTU4VFRR9Fd4VGdsYTMfVmepNHLrJXYtJXZ0F2dvwVZnFWbp1zczV2YvJHctM3cv1Ce-YWan5COjF2YhFDN4EDMhhDOwIDNwYjY4gDMjVjM5QWM2YTYy8CX1AzLchDMxIDMy8CXn9Gbi9CXzV2Zh1WavwVbvNmLvR3YxUjLzM3Lc9CX6MHc0RHaiojIsJye.gif)
#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