https://www.acmicpc.net/problem/28069
28069번: 김밥천국의 계단
첫 번째 줄에 계단 개수에 해당하는 $N$, 계단을 오르는 횟수 $K$가 주어진다. $(1 \leq N, K \leq 1\,000\,000)$
www.acmicpc.net
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.StringTokenizer;
public class Main {
public static void main(String[] args) throws Exception {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
StringTokenizer st = new StringTokenizer(br.readLine(), " ");
int N = Integer.parseInt(st.nextToken());
int K = Integer.parseInt(st.nextToken());
if (N <= K) {
System.out.print("minigimbob");
return;
}
int mod;
while (K < N) {
mod = N % 3;
if (mod == 2) --N;
else N = N / 3 * 2 + mod;
if (--K == 0) {
System.out.print("water");
return;
}
}
System.out.print("minigimbob");
}
}
'OJ' 카테고리의 다른 글
[BOJ] 28066 타노스는 요세푸스가 밉다 (JAVA) (0) | 2023.07.24 |
---|---|
[BOJ] 28065 SW 수열 구하기 (JAVA) (0) | 2023.07.23 |
[BOJ] 1021 회전하는 큐 (JAVA) (0) | 2023.07.21 |
[BOJ] 1789 수들의 합 (JAVA) (0) | 2023.07.20 |
[BOJ] 2108 통계학 (JAVA) (0) | 2023.07.19 |