From 18e4a6400fad20cafb462e5780a8e830a862c0ff Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B9=80=EB=AF=BC=EC=A7=84?= Date: Thu, 27 Nov 2025 10:49:20 +0900 Subject: [PATCH] =?UTF-8?q?[20251127]=20BOJ=20/=20G3=20/=20=EC=83=89?= =?UTF-8?q?=EC=83=81=ED=99=98=20/=20=EA=B9=80=EB=AF=BC=EC=A7=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...3 \354\203\211\354\203\201\355\231\230.md" | 44 +++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 "zinnnn37/202511/27 BOJ G3 \354\203\211\354\203\201\355\231\230.md" diff --git "a/zinnnn37/202511/27 BOJ G3 \354\203\211\354\203\201\355\231\230.md" "b/zinnnn37/202511/27 BOJ G3 \354\203\211\354\203\201\355\231\230.md" new file mode 100644 index 00000000..d261743e --- /dev/null +++ "b/zinnnn37/202511/27 BOJ G3 \354\203\211\354\203\201\355\231\230.md" @@ -0,0 +1,44 @@ +```java +import java.io.*; + +public class BJ_G3_색상환 { + + private static final int MOD = 1_000_000_003; + + private static final BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); + private static final BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out)); + + private static int N, K; + private static int[][] dp; + + public static void main(String[] args) throws IOException { + init(); + sol(); + } + + private static void init() throws IOException { + N = Integer.parseInt(br.readLine()); + K = Integer.parseInt(br.readLine()); + + dp = new int[N + 1][K + 1]; + for (int i = 0; i <= N; i++) { + dp[i][0] = 1; + if (i >= 1) dp[i][1] = i; + } + } + + private static void sol() throws IOException { + for (int i = 4; i <= N; i++) { + for (int j = 2; j <= K; j++) { + dp[i][j] = (dp[i - 1][j] + dp[i - 2][j - 1]) % MOD; + } + } + + bw.write(dp[N][K] + ""); + bw.flush(); + bw.close(); + br.close(); + } + +} +``` \ No newline at end of file