From fef9210ce1b73041522fca6bdabce3c6a250ec0d Mon Sep 17 00:00:00 2001 From: oncsr Date: Tue, 23 Sep 2025 20:51:58 +0900 Subject: [PATCH] =?UTF-8?q?[20250923]=20BOJ=20/=20G3=20/=20Number=20Reduct?= =?UTF-8?q?ion=20/=20=EA=B6=8C=ED=98=81=EC=A4=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- khj20006/202509/23 BOJ G3 Number Reduction.md | 83 +++++++++++++++++++ 1 file changed, 83 insertions(+) create mode 100644 khj20006/202509/23 BOJ G3 Number Reduction.md diff --git a/khj20006/202509/23 BOJ G3 Number Reduction.md b/khj20006/202509/23 BOJ G3 Number Reduction.md new file mode 100644 index 00000000..f8729629 --- /dev/null +++ b/khj20006/202509/23 BOJ G3 Number Reduction.md @@ -0,0 +1,83 @@ +```java +import java.io.*; +import java.util.*; + +class IOController { + BufferedReader br; + BufferedWriter bw; + StringTokenizer st; + + public IOController() { + br = new BufferedReader(new InputStreamReader(System.in)); + bw = new BufferedWriter(new OutputStreamWriter(System.out)); + st = new StringTokenizer(""); + } + + String nextLine() throws Exception { + String line = br.readLine(); + st = new StringTokenizer(line); + return line; + } + + String nextToken() throws Exception { + while (!st.hasMoreTokens()) + nextLine(); + return st.nextToken(); + } + + int nextInt() throws Exception { + return Integer.parseInt(nextToken()); + } + + long nextLong() throws Exception { + return Long.parseLong(nextToken()); + } + + double nextDouble() throws Exception { + return Double.parseDouble(nextToken()); + } + + void close() throws Exception { + bw.flush(); + bw.close(); + } + + void write(String content) throws Exception { + bw.write(content); + } + +} + +public class Main { + + static IOController io; + + // + + static long N; + static TreeSet set = new TreeSet<>(); + + public static void main(String[] args) throws Exception { + + io = new IOController(); + + N = io.nextLong(); + set.add(1L); + bck(1); + io.write(set.size() + "\n"); + + io.close(); + + } + + static void bck(long s) { + for(int i=2;i<=9;i++) if(s*i <= N) { + if(!set.contains(s*i) && Long.toString(s*i).contains(Integer.toString(i))) { + set.add(s*i); + bck(s*i); + } + } + } + +} +```