Thursday, February 5, 2015

Solution of 119A. Epic Game ( Codeforces )

#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<algorithm>
using namespace std;
#define sf scanf
#define pf printf
typedef long long ll;

int gcd(int a, int b)
{
    if(b==0)
    {
        return a;
    }
    return gcd(b, a%b);
}

int main()
{
    int a, b, n;
    sf("%d%d%d", &a, &b, &n);
    while(1)
    {
        n= n-gcd(a, n);
        if(n<=0)
        {
            pf("0\n");
            break;
        }
        n= n-gcd(b, n);
        if(n<=0)
        {
            pf("1\n");
            break;
        }
    }
}

No comments:

Post a Comment

Compare equality of two string in C

#include <stdio.h> #include<string.h> int main() {     char* country = "Bangladesh";     char* country2;     ...