Skip to content

Instantly share code, notes, and snippets.

@Jack-Saleem
Created July 17, 2016 13:41
Show Gist options
  • Save Jack-Saleem/e0c4978d197fc97ce88d6726e6d5745c to your computer and use it in GitHub Desktop.
Save Jack-Saleem/e0c4978d197fc97ce88d6726e6d5745c to your computer and use it in GitHub Desktop.
codeforces 119A EpicGame program in java
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