Codeforces119A简单的GCD博弈

来源:互联网 发布:sqlserver存储过程 编辑:程序博客网 时间:2024/05/13 13:24
//这个水题目也让我调试了半天.我郁闷..水啊..
//错误出在函数里面..函数的参数最开始是a,b和外面的实参是一样的..
//这样子使得结果不对..为什么不用去管..以后记住就行了.
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<iostream>
#include<math.h>
#include<vector>
const int inf = 0x3f3f3f;
using namespace std;
int Comdiv(int x,int y)
{
    int c = 1;
    while(c != 0)
    {
        c = x % y;
        x = y;
        y = c;
    }
    return x;
}
int main()
{
    int a,b,n;
    while(scanf("%d%d%d",&a,&b,&n) != EOF)
    {
        bool vis = 1;
        while(n > 0)
        {
            n = n - Comdiv(a,n);
            if(n < 0)
            {
                vis = 0;
            }
            else
            {
                if(n > 0 )
                {
                     n = n - Comdiv(b,n);
                     if(n == 0)vis = 0;
                }


            }
        }
        if(vis)printf("0\n");
        else printf("1\n");
    }
}
原创粉丝点击