From 09a08435e527b82662bcbdb91ecda8ecd2b0b5e4 Mon Sep 17 00:00:00 2001 From: suyeun84 <81475092+suyeun84@users.noreply.github.com> Date: Fri, 4 Apr 2025 11:40:46 +0900 Subject: [PATCH] =?UTF-8?q?[20250404]=20BOJ=20/=20G5=20/=20=EB=B9=8C?= =?UTF-8?q?=EB=9F=B0=20=ED=98=B8=EC=84=9D=20/=20=EA=B9=80=EC=88=98?= =?UTF-8?q?=EC=97=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...4\353\237\260 \355\230\270\354\204\235.md" | 48 +++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100644 "suyeun84/202504/04 BOJ G5 \353\271\214\353\237\260 \355\230\270\354\204\235.md" diff --git "a/suyeun84/202504/04 BOJ G5 \353\271\214\353\237\260 \355\230\270\354\204\235.md" "b/suyeun84/202504/04 BOJ G5 \353\271\214\353\237\260 \355\230\270\354\204\235.md" new file mode 100644 index 00000000..1155311f --- /dev/null +++ "b/suyeun84/202504/04 BOJ G5 \353\271\214\353\237\260 \355\230\270\354\204\235.md" @@ -0,0 +1,48 @@ +```java +import java.io.*; +import java.util.*; + +public class boj22251 { + static BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); + static StringTokenizer st; + static void nextLine() throws Exception {st = new StringTokenizer(br.readLine());} + static int nextInt() {return Integer.parseInt(st.nextToken());} + + static int[][] digit = { + {0, 4, 3, 3, 4, 3, 2, 3, 1, 2}, + {4, 0, 5, 3, 2, 5, 6, 1, 5, 4}, + {3, 5, 0, 2, 5, 4, 3, 4, 2, 3}, + {3, 3, 2, 0, 3, 2, 3, 2, 2, 1}, + {4, 2, 5, 3, 0, 3, 4, 3, 3, 2}, + {3, 5, 4, 2, 3, 0, 1, 4, 2, 1}, + {2, 6, 3, 3, 4, 1, 0, 5, 1, 2}, + {3, 1, 4, 2, 3, 4, 5, 0, 4, 3}, + {1, 5, 2, 2, 3, 2, 1, 4, 0, 1}, + {2, 4, 3, 1, 2, 1, 2, 3, 1, 0} + }; + static int N, K, P, X, answer; + public static void main(String[] args) throws Exception { + nextLine(); + N = nextInt(); // N층까지 이용 가능 + K = nextInt(); // 숫자 길이 + P = nextInt(); // 1~P개 반전 + X = nextInt(); // 실제 층 + + solve(0, 1, 0, 0); + + System.out.println(answer-1); + } + + static void solve(int idx, int ten, int now, int cnt) { + if (now > N || cnt > P) return; + if (idx == K) { + if (now != 0) answer++; + return; + } + for(int i = 0; i < 10; i++) { + solve(idx+1, ten*10, i*ten+now, cnt+digit[X/ten%10][i]); + } + } +} + +```