More actions
imported>talin0528 No edit summary |
(Repair batch-0002 pages from live compare) |
||
| Line 1: | Line 1: | ||
== Status == | == Status == | ||
{| class="wikitable" | {| class="wikitable" style="width:100%;" | ||
|- | |- | ||
| Problem | | Problem | ||
| Line 21: | Line 21: | ||
import java.util.Scanner; | import java.util.Scanner; | ||
public class Main{ | public class Main{ | ||
public static void main(String | public static void main(String[] args) { | ||
Scanner sc = new Scanner(System.in); | Scanner sc = new Scanner(System.in); | ||
while(sc.hasNextInt()){ | while(sc.hasNextInt()){ | ||
| Line 49: | Line 49: | ||
} | } | ||
== Trial and Error == | == Trial and Error == | ||
* 왜 중간단계로 | * 왜 중간단계로 11 7이 나오는 지 이해가 안 갔었다. 베스킨라빈스31 게임처럼 숫자를 자유롭게 부르되 이기려면 절대적으로 불러야하는 숫자가 있는 것처럼, 이 것도 처음 시작하는 사람이 이기려고 일부러 덜 뺀 거였다 ㄷㄷ | ||
25 7 | 25 7 | ||
| Line 64: | Line 64: | ||
---- | ---- | ||
[[ACM_ICPC/2011년스터디]] | [[ACM_ICPC/2011년스터디]] | ||
Latest revision as of 00:16, 27 March 2026
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");
}
}
}
Trial and Error
- 왜 중간단계로 11 7이 나오는 지 이해가 안 갔었다. 베스킨라빈스31 게임처럼 숫자를 자유롭게 부르되 이기려면 절대적으로 불러야하는 숫자가 있는 것처럼, 이 것도 처음 시작하는 사람이 이기려고 일부러 덜 뺀 거였다 ㄷㄷ
25 7
11 7
4 7
4 3
1 3
1 0