天天看点

NYOJ 161 取石子 (四) (威佐夫博弈)

取石子 (四)

时间限制:1000 ms | 内存限制:65535 KB

难度:4

描述

有两堆石子,数量任意,可以不同。游戏开始由两个人轮流取石子。游戏规定,每次有两种不同的取法,一是可以在任意的一堆中取走任意多的石子;二是可以在两堆中同时取走相同数量的石子。最后把石子全部取完者为胜者。现在给出初始的两堆石子的数目,如果轮到你先取,假设双方都采取最好的策略,问最后你是胜者还是败者。

输入

输入包含若干行,表示若干种石子的初始情况,其中每一行包含两个非负整数a和b,表示两堆石子的数目,a和b都不大于1,000,000,000。

输出

输出对应也有若干行,每行包含一个数字1或0,如果最后你是胜者,则为1,反之,则为0。

样例输入

2 1
8 4
4 7
           

样例输出

0
1
0
           

ac代码:

/* ***********************************************
Author       : AnICoo1
Created Time : 2016-07-27-11.00 Wednesday
File Name    : D:\MyCode\2016-7月\2016-7-27-2.cpp
LANGUAGE     : C++
Copyright  2016 clh All Rights Reserved
************************************************ */
#include<stdio.h>
#include<math.h>
#include<string.h>
#include<stack>
#include<set>
#include<map>
#include<queue>
#include<vector>
#include<iostream>
#include<algorithm>
#define MAXN 1010000
#define LL long long
#define INF 0xfffffff
#define mem(x) memset(x,0,sizeof(x))
#define PI acos(-1)
#define eps 1e-8
using namespace std;
//head
int main()
{
    int n,m;
    while(scanf("%d%d",&n,&m)!=EOF)
    {
        if(n<m) swap(n,m);
        int k=n-m;
        int n=(int)k*(+sqrt())/;
        if(n==m)
            printf("0\n");
        else
            printf("1\n");

    }
    return ;
}