
-Code
import java.util.Scanner;
public class BOJ6795 {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int a = sc.nextInt();
int b = sc.nextInt();
int c = sc.nextInt();
int d = sc.nextInt();
int s = sc.nextInt();
int nikkyStep = simulation(a, b, s);
int byronStep = simulation(c, d, s);
if (nikkyStep > byronStep) {
System.out.println("Nikky");
} else if (nikkyStep < byronStep) {
System.out.println("Byron");
} else {
System.out.println("Tied");
}
}
// 위치 계산
private static int simulation(int front, int back, int total) {
int pos = 0;
int cycle = front + back;
for (int i = 0; i < total; i++) {
// 앞으로 가는 숫자보다 작으면 앞으로 아니면 뒤로
pos += i % cycle < front ? 1 : -1;
}
return pos;
}
}'Beakjoon&프로그래머스 > Java' 카테고리의 다른 글
| [백준/Java] 3009번 네 번째 점 (0) | 2025.12.19 |
|---|---|
| [백준/Java] 2442번 별 찍기 - 5 (0) | 2025.12.19 |
| [백준/Java] 31497번 생일 축하합니다~ (0) | 2025.12.18 |
| [백준/Java] 34917번 M (0) | 2025.12.17 |
| [백준/Java] 10384번 팬그램 (0) | 2025.12.16 |