hdu2177威佐夫博弈

输的话输出0,赢就输出1并且输出第一步走后的数目

威佐夫博弈判断胜负

原理及常见题型求法:

http://blog.csdn.net/y990041769/article/details/21694007

#include<map>
#include<set>
#include<cmath>
#include<queue>
#include<stack>
#include<vector>
#include<cstdio>
#include<cassert>
#include<iomanip>
#include<cstdlib>
#include<cstring>
#include<iostream>
#include<algorithm>
#define pi acos(-1)
#define ll long long
#define mod 1000000007
#define ls l,m,rt<<1
#define rs m+1,r,rt<<1|1
#pragma comment(linker, "/STACK:1024000000,1024000000")

using namespace std;

const double g=10.0,eps=1e-9;
const int N=100000+10,maxn=111117,inf=11111;

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n,m;
    while(cin>>n>>m,n&&m){
        int k=m-n,t=k*(1+sqrt(5))/2;
        if(n==t)cout<<0<<endl;
        else
        {
            cout<<1<<endl;
            if(t<n)cout<<t<<" "<<m-n+t<<endl;//取两个相同数的情况
            for(int i=1;;i++)//i是间隔
            {
                int t=i*(1+sqrt(5))/2;
                if(t>=m)break;
                if(n==t&&m-i>n)cout<<n<<" "<<n+i<<endl;//从m中取,取完m比n大
                else if(n-i==t)cout<<t<<" "<<t+i<<endl;//从m中取,取完m比n小
                else if(m==t+i&&n>t)cout<<t<<" "<<t+i<<endl;//从n中取
            }
        }
    }
    return 0;
}
View Code
原文地址:https://www.cnblogs.com/acjiumeng/p/7056446.html