From 9f06896dc2d681aaa1f9e3ee0514b53def289d52 Mon Sep 17 00:00:00 2001 From: lkhyun <102892446+lkhyun@users.noreply.github.com> Date: Tue, 25 Nov 2025 14:04:53 +0900 Subject: [PATCH] =?UTF-8?q?[20251125]=20BOJ=20/=20G3=20/=20=EC=83=89?= =?UTF-8?q?=EC=83=81=ED=99=98=20/=20=EC=9D=B4=EA=B0=95=ED=98=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" | 34 +++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 "lkhyun/202511/25 BOJ G3 \354\203\211\354\203\201\355\231\230.md" diff --git "a/lkhyun/202511/25 BOJ G3 \354\203\211\354\203\201\355\231\230.md" "b/lkhyun/202511/25 BOJ G3 \354\203\211\354\203\201\355\231\230.md" new file mode 100644 index 00000000..6fec2ffb --- /dev/null +++ "b/lkhyun/202511/25 BOJ G3 \354\203\211\354\203\201\355\231\230.md" @@ -0,0 +1,34 @@ +```java +import java.util.*; +import java.io.*; + +public class Main{ + static BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); + static BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out)); + static StringTokenizer st; + static StringBuilder sb = new StringBuilder(); + static int N,K; + static int[][] dp; + static int MOD = 1000000003; + + public static void main(String[] args) throws Exception { + N = Integer.parseInt(br.readLine()); + K = Integer.parseInt(br.readLine()); + dp = new int[N+1][K+1]; //N개의 색중 K개를 선택하는 경우의 수 + + for(int i=0;i<=N;i++){ + dp[i][1] = i; //색 i를 칠하는 경우의 수 여기서 1개를 색칠하는 경우는 i개임. + dp[i][0] = 1; + } + for(int i = 2;i<=N;i++){ + for(int j = 2;j<=K;j++){ + dp[i][j] = (dp[i-1][j] + dp[i-2][j-1]) % MOD; + } + } + + int ans = (dp[N-1][K] + dp[N-3][K-1]) % MOD; + bw.write(ans+""); + bw.close(); + } +} +```