From abcaa182c6f930452ca33c3f77bfdd1f9af219e1 Mon Sep 17 00:00:00 2001 From: Ukj0ng <90972240+Ukj0ng@users.noreply.github.com> Date: Sat, 17 Jan 2026 10:44:36 +0900 Subject: [PATCH] =?UTF-8?q?[20260117]=20BOJ=20/=20G5=20/=20=EC=95=8C?= =?UTF-8?q?=EC=95=BD=20/=20=ED=95=9C=EC=A2=85=EC=9A=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../17 BOJ G5 \354\225\214\354\225\275.md" | 42 +++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 "Ukj0ng/202601/17 BOJ G5 \354\225\214\354\225\275.md" diff --git "a/Ukj0ng/202601/17 BOJ G5 \354\225\214\354\225\275.md" "b/Ukj0ng/202601/17 BOJ G5 \354\225\214\354\225\275.md" new file mode 100644 index 00000000..5953ef6b --- /dev/null +++ "b/Ukj0ng/202601/17 BOJ G5 \354\225\214\354\225\275.md" @@ -0,0 +1,42 @@ +``` +import java.io.*; + +public class Main { + private static final BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); + private static final BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out)); + private static long[][] dp; + private static int N; + + public static void main(String[] args) throws IOException { + init(); + + bw.flush(); + bw.close(); + br.close(); + } + + private static void init() throws IOException { + while (true) { + N = Integer.parseInt(br.readLine()); + if (N == 0) return; + + dp = new long[N+1][N+1]; + + for (int i = 0; i <= N; i++) { + dp[0][i] = 1; + } + + for (int i = 1; i <= N; i++) { + for (int j = 0; j <= N; j++) { + + if (j+1 <= N)dp[i][j] += dp[i-1][j+1]; + + if (j > 0) dp[i][j] += dp[i][j-1]; + } + } + + bw.write(dp[N][0] + "\n"); + } + } +} +```