-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathA. Insomnia cure.cs
48 lines (44 loc) · 1.16 KB
/
A. Insomnia cure.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication14
{
class Program
{
static void Main(string[] args)
{
String[] line = Console.ReadLine().Split(' ');
int Simon = int.Parse(line[0]);
int AntiSimon = int.Parse(line[1]);
int heap = int.Parse(line[2]);
for (int i = 0; ; i++)
{
if (i%2 == 0)
{
heap -= GCD(Simon, heap);
if (heap < 0)
{
Console.WriteLine("1");
break;
}
}
else
{
heap -= GCD(AntiSimon, heap);
if (heap < 0)
{
Console.WriteLine("0");
break;
}
}
}
Console.ReadLine();
}
public static int GCD (int A, int B)
{
return B == 0 ? A : GCD(B , A % B);
}
}
}