这篇是博弈论解~\(≧▽≦)/~啦啦啦

感觉还是很妙的

推荐两个博客

http://blog.csdn.net/qiankun1993/article/details/6765688

http://blog.csdn.net/luomingjun12315/article/details/45479073

感觉自己写不出比他们更好的了,就贴贴代码吧。。。

poj1704:

#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<cmath>
#include<algorithm>
#include<iostream>
#include<string>
#include<queue>
#include<map>
#include<set>
#include<vector>
#define mp make_pair
#define fi first
#define se second
#define sqr(x) (x)*(x)
#define rep(i,x,y) for (int i=(x);i<=(y);i++)
#define per(i,x,y) for (int i=(x);i>=(y);i--)
using namespace std;
typedef long long LL;
typedef double DBD;
typedef pair<int,int> pa;
const int inf=1e9;
const LL INF=1e18;
//-----------------------------------------------head-------------------------------------------//
const int N=100010;
int T,n,a[N];
int Write[20];
int read() {int d=0,f=1; char c=getchar(); while (c<'0'||c>'9') {if (c=='-') f=-1; c=getchar();} while (c>='0'&&c<='9') d=(d<<3)+(d<<1)+c-48,c=getchar(); return d*f;}
void write(int x){int t=0; if (x<0) putchar('-'),x=-x; for (;x;x/=10) Write[++t]=x%10; if (!t) putchar('0'); for (int i=t;i>=1;i--) putchar((char)(Write[i]+48));}
void judge(){freopen(".in","r",stdin); freopen(".out","w",stdout);}
int main()
{
    //judge();
    T=read();
    while (T--)
    {
        n=read();
        for (int i=1;i<=n;i++) a[i]=read();
        sort(a+1,a+1+n);
        int ans=0;
        for (int i=n;i>=1;i-=2)
        {
            if (n==1) ans^=a[1]-1;
            else ans^=a[i]-a[i-1]-1;
        }
        if (!ans) puts("Bob will win");
        else puts("Georgia will win");
    }
    return 0;
}
View Code

poj1067:

#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<cmath>
#include<algorithm>
#include<iostream>
#include<string>
#include<queue>
#include<map>
#include<set>
#include<vector>
#define mp make_pair
#define fi first
#define se second
#define sqr(x) (x)*(x)
#define rep(i,x,y) for (int i=(x);i<=(y);i++)
#define per(i,x,y) for (int i=(x);i>=(y);i--)
using namespace std;
typedef long long LL;
typedef double DBD;
typedef pair<int,int> pa;
const int inf=1e9;
const LL INF=1e18;
//-----------------------------------------------head-------------------------------------------//
int a,b;
const DBD q=(sqrt(5.0)+1)/2.0;
int Write[20];
int read() {int d=0,f=1; char c=getchar(); while (c<'0'||c>'9') {if (c=='-') f=-1; c=getchar();} while (c>='0'&&c<='9') d=(d<<3)+(d<<1)+c-48,c=getchar(); return d*f;}
void write(int x){int t=0; if (x<0) putchar('-'),x=-x; for (;x;x/=10) Write[++t]=x%10; if (!t) putchar('0'); for (int i=t;i>=1;i--) putchar((char)(Write[i]+48));}
void judge(){freopen(".in","r",stdin); freopen(".out","w",stdout);}
int wythoff(int a,int b)
{
    if (a>b) swap(a,b);
    int k=b-a;
    if (a==(int)(k*q)) return 0;
    return 1;
}
int main()
{
    //judge();
    while (scanf("%d%d",&a,&b)!=EOF) {printf("%d\n",wythoff(a,b));}
    return 0;
}
View Code