PKU 1067 取石子游戏

#include <iostream>
#include 
<algorithm>
#include 
<cmath>
using namespace std;
int main()
{
     
int ax,bx,temp;
     
int k,wantedax;
     
while(scanf("%d%d",&ax,&bx)!=EOF) /*题中没有输入结标志时,必须这样写,否则会WA*/
     
{
            
if(ax>bx)
                swap(ax,bx);
            k 
= bx - ax;
            wantedax 
= (floor)( k*(1.0+sqrt(5.0))/2.0 );
            
if(ax==wantedax)
                printf(
"%d\n",0);
            
else
                printf(
"%d\n",1);
    }

    
return 0;
}

posted @ 2009-04-29 16:54  黄浩贤  阅读(258)  评论(0编辑  收藏  举报