From c84f50d0ac293c6e14cc04cc9b3caab11f66719f Mon Sep 17 00:00:00 2001 From: LiiNi-coder <97495437+LiiNi-coder@users.noreply.github.com> Date: Thu, 19 Feb 2026 23:48:21 +0900 Subject: [PATCH] =?UTF-8?q?[20260219]=20BOJ=20/=20G5=20/=20=EC=8B=A0?= =?UTF-8?q?=EA=B8=B0=ED=95=9C=20=EC=86=8C=EC=88=98=20/=20=EC=9D=B4?= =?UTF-8?q?=EC=9D=B8=ED=9D=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...0\355\225\234 \354\206\214\354\210\230.md" | 47 +++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 "LiiNi-coder/202602/19 BOJ \354\213\240\352\270\260\355\225\234 \354\206\214\354\210\230.md" diff --git "a/LiiNi-coder/202602/19 BOJ \354\213\240\352\270\260\355\225\234 \354\206\214\354\210\230.md" "b/LiiNi-coder/202602/19 BOJ \354\213\240\352\270\260\355\225\234 \354\206\214\354\210\230.md" new file mode 100644 index 00000000..e0bc4982 --- /dev/null +++ "b/LiiNi-coder/202602/19 BOJ \354\213\240\352\270\260\355\225\234 \354\206\214\354\210\230.md" @@ -0,0 +1,47 @@ +```java +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStreamReader; + +public class Main { + static int N; + public static void main(String[] args) throws IOException { + BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); + N = Integer.parseInt(br.readLine()); + //1자리 소수로 모두 시작 + startTo(1, 2, N); + startTo(1, 3, N); + startTo(1, 5, N); + startTo(1, 7, N); + } + + private static void startTo(int depth, int value, int n) { + if (!isPrime(value)) { + return; + } + if (depth == n) { + System.out.println(value); + return; + } + + + for (int digit = 1; digit <= 9; digit++) { + int next = value * 10 + digit; + startTo(depth + 1, next, n); + } + } + + private static boolean isPrime(int num) { + if (num < 2) { + return false; + } + for (int i = 2; i * i <= num; i++) { + if (num % i == 0) { + return false; + } + } + return true; + } +} + +```