威佐夫博弈(C语言)

威佐夫博弈(Wythoff's game):有两堆各若干个物品,两个人轮流从任一堆取至少一个或同时从两堆中取同样多的物品,规定每次至少取一个,多者不限,最后取光者得胜。
#include <stdio.h>
#include <math.h>
#include <string.h>
const double Gsr=(1+sqrt(5.0))/2;
void swap(int *a,int *b)
{
    int t=*b;
    *b=*a;
    *a=t;
}
int main()
{
    int a,b;
    while(~scanf("%d%d",&a,&b))
    {
        if(a>b)
        {
            swap(&a,&b);
        }
        if(a == (int)(Gsr*(b-a))) //奇异局势,先手输
            puts("First Lose");
        else
            puts("First Win");
    }
    return 0;
}


猜你喜欢

转载自blog.csdn.net/uzzzhf/article/details/80094653
今日推荐