博弈知识汇总:http://www.wutianqi.com/?p=1081
hdu 1527:
#include<cstdio>
#include<cstring>
#include<stdlib.h>
#include<algorithm>
#include<iostream>
#include<math.h>
#include<vector>
using namespace std;
#define ll long long
int main()
{
int n,m;
double t=(1+sqrt(5.0))/2;
while(scanf("%d%d",&n,&m)!=EOF)
{
if(n>m) swap(n,m);
int k=m-n;
if((int)(t*k)==n)
printf("0\n");
else
printf("1\n");
}
}
hdu 2177:
#include<cstdio>
#include<cstring>
#include<stdlib.h>
#include<algorithm>
#include<iostream>
#include<math.h>
#include<vector>
using namespace std;
#define ll long long
int main()
{
int n,m;
double t=(1+sqrt(5.0))/2;
while(scanf("%d%d",&n,&m)!=EOF,n+m)
{
if(n>m) swap(n,m);
int k=m-n;
int te=(int)(t*k);
if(te==n)
printf("0\n");
else
{
printf("1\n");
if(te<n)
{
printf("%d %d\n",te,te+k);
printf("%d %d\n",(int)(n*t/(t+1)),n);
}
else
{
int a=n;
int k=((int)((double)n/t))+1;
if((int)(t*k)==a)
printf("%d %d\n",n,k+n);
else
printf("%d %d\n",(int)(n*t/(t+1)),n);
}
}
}
}