Created
July 17, 2016 13:41
-
-
Save Jack-Saleem/e0c4978d197fc97ce88d6726e6d5745c to your computer and use it in GitHub Desktop.
codeforces 119A EpicGame program in java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.Scanner; | |
public class EpicGame | |
{ | |
int GCD(int x,int y) | |
{ | |
if(y==0){ | |
return x; | |
} | |
return GCD(y,x%y); | |
} | |
public static void main(String[] args) | |
{ | |
EpicGame eg=new EpicGame(); | |
Scanner z=new Scanner(System.in); | |
int a=z.nextInt(); | |
int b=z.nextInt(); | |
int n=z.nextInt(); | |
int[] arr={a,b}; | |
int j=0,t=0,t1=3; | |
while(true) { | |
for(int i=0;i<arr.length;i++) { | |
t=eg.GCD(arr[i], n); | |
n=n-t; | |
if(n<0){ | |
t1=i; | |
break; | |
} | |
} | |
if(t1==1){ | |
System.out.println(0); | |
break; | |
} | |
if(t1==0){ | |
System.out.println(1); | |
break; | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment