Advertisement
Serega

Epic Game

Oct 17th, 2011
4,741
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.27 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3. int gcd(int x, int y)
  4. {
  5.     return (x==0)? y : gcd(y % x, x);
  6. }
  7. int main()
  8. {
  9.     int a, b, n;
  10.     cin >> a >> b >> n;
  11.     int k = 0;
  12.     while (n >= 0)
  13.     {
  14.         ++k;
  15.         n -= gcd((k & 1) ? a : b, n);
  16.     }
  17.     if (k & 1) cout << 1; else cout << 0;
  18. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement