Codeforces119A简单的GCD博弈

7 篇文章 0 订阅
1 篇文章 0 订阅
//这个水题目也让我调试了半天.我郁闷..水啊..
//错误出在函数里面..函数的参数最开始是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");
    }
}
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值