码迷,mamicode.com
首页 > 其他好文 > 详细

威佐夫博奕(Wythoff Game)

时间:2017-06-18 21:54:37      阅读:217      评论:0      收藏:0      [点我收藏+]

标签:cout   stream   comment   ios   comm   include   game   end   span   

出现奇异局面,先取者必败,反之后拿者必败

奇异局面:(0,0) (1,2) (3,5) (4,7) (ak,bk)

ak=bk-k,ak=k*(1+√5)/2;

代码实现(poj 1067):

#include<cstdio>
#include<cstring>
#include<iostream>
#include<cmath>
using namespace std;
int main()
{
	double v=(sqrt(5.0)+1)/2;
	int a,b;
	while(~scanf("%d %d",&a,&b))
	{
		int k=a>b?a-b:b-a;
		//cout<<k<<endl;
		if(a>b) swap(a,b);
		if(floor(k*v)==a)
		{
			//cout<<k<<" "<<v<<endl;
			cout<<"0"<<endl;
		}
		else
		{
			cout<<"1"<<endl;
		}
	}
    return 0;
}

威佐夫博奕(Wythoff Game)

标签:cout   stream   comment   ios   comm   include   game   end   span   

原文地址:http://www.cnblogs.com/chinacwj/p/7045325.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!