Difference between r1.3 and the current
@@ -14,11 +14,6 @@
int r2 = sc.nextInt();
if(r1==0 && r2==0)
break;
if(r2>r1){
int temp = r1;
r1 = r2;
r2 = temp;
}
playGame(r1,r2);
}
}
if(r1==0 && r2==0)
break;
}
}
@@ -26,12 +21,11 @@
int g, r, count=0;
while(r1%r2!=0){
g = r1/r2;
break;
r1 = r2;
r2 = r;
count++;
}
if(count%2 == 1){
System.out.println("Ollie wins");
while(r1%r2!=0){
g = r1/r2;
if(g>1)
if(g>1) break;
if(r1>=r2) count++;
r = r1-g*r2;r1 = r2;
r2 = r;
if(count%2 == 1){
System.out.println("Ollie wins");
Status ¶
Problem | 2348 | User | talin0528 |
Memory | 3516K | Time | 297MS |
Language | Java | Result | Accepted |
Source ¶
import java.util.Scanner; public class Main{ public static void main(String[] args) { Scanner sc = new Scanner(System.in); while(sc.hasNextInt()){ int r1 = sc.nextInt(); int r2 = sc.nextInt(); if(r1==0 && r2==0) break; playGame(r1,r2); } } private static void playGame(int r1, int r2) { int g, r, count=0; while(r1%r2!=0){ g = r1/r2; if(g>1) break; if(r1>=r2) count++; r = r1-g*r2; r1 = r2; r2 = r; } if(count%2 == 1){ System.out.println("Ollie wins"); }else{ System.out.println("Stan wins"); } } }