[SHOI2002]取石子游戏之三


Wythoff's Game,详解请见浅谈算法——博弈论中的例6

/*program from Wolfycz*/
#include<cmath>
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
#define inf 0x7f7f7f7f
using namespace std;
typedef long long ll;
typedef unsigned int ui;
typedef unsigned long long ull;
inline int read(){
	int x=0,f=1;char ch=getchar();
	for (;ch<'0'||ch>'9';ch=getchar())	if (ch=='-')    f=-1;
	for (;ch>='0'&&ch<='9';ch=getchar())	x=(x<<1)+(x<<3)+ch-'0';
	return x*f;
}
inline void print(int x){
	if (x>=10)     print(x/10);
	putchar(x%10+'0');
}
int main(){
	int n,m;
	while (~scanf("%d%d",&n,&m)){
		if (n<m)	swap(n,m);
		putchar(trunc(1.0*(n-m)*(1+sqrt(5))/2)==m?'0':'1');
		putchar('\n');
	}
	return 0;
}

相关文章:

  • 2021-10-11
  • 2021-07-03
  • 2021-09-03
  • 2021-10-28
  • 2021-08-28
  • 2021-07-24
  • 2022-03-04
猜你喜欢
  • 2022-12-23
  • 2021-06-04
  • 2021-10-02
相关资源
相似解决方案