From 9ada274835359db45e94ac755cf6ff6117abd416 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B0=95=EC=88=98=EB=AF=BC?= Date: Mon, 6 Jan 2025 09:54:04 +0900 Subject: [PATCH] CT_352 --- ...\354\240\204\352\262\214\354\236\204.java" | 32 +++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 "BOJ/Java/src/S3/Boj_10837_\353\217\231\354\240\204\352\262\214\354\236\204.java" diff --git "a/BOJ/Java/src/S3/Boj_10837_\353\217\231\354\240\204\352\262\214\354\236\204.java" "b/BOJ/Java/src/S3/Boj_10837_\353\217\231\354\240\204\352\262\214\354\236\204.java" new file mode 100644 index 0000000..bd40012 --- /dev/null +++ "b/BOJ/Java/src/S3/Boj_10837_\353\217\231\354\240\204\352\262\214\354\236\204.java" @@ -0,0 +1,32 @@ +package S3; + +import java.io.*; +import java.util.StringTokenizer; + +public class Boj_10837_동전게임 { + public static void main(String[] args) throws IOException { + BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); + BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out)); + StringBuilder sb = new StringBuilder(); + + int K = Integer.parseInt(br.readLine()); + int C = Integer.parseInt(br.readLine()); + + for (int i = 0; i < C; i++) { + StringTokenizer st = new StringTokenizer(br.readLine()); + int N = Integer.parseInt(st.nextToken()); + int M = Integer.parseInt(st.nextToken()); + + if (N > M) { + sb.append(N - M - (K - N) <= 2 ? 1 : 0).append('\n'); + } else if (N < M) { + sb.append(M - N - (K - M) <= 1 ? 1 : 0).append('\n'); + } else { + sb.append(1).append('\n'); + } + } + + bw.write(sb.toString()); + bw.flush(); + } +}