From 59d7723ca0e2bb52d5b2216ca33933d03200d77c Mon Sep 17 00:00:00 2001 From: oncsr Date: Wed, 9 Jul 2025 13:11:38 +0900 Subject: [PATCH] =?UTF-8?q?[20250709]=20BOJ=20/=20G1=20/=20=EC=84=9C?= =?UTF-8?q?=EB=A1=9C=EC=86=8C=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 --- ...1 \354\204\234\353\241\234\354\206\214.md" | 114 ++++++++++++++++++ 1 file changed, 114 insertions(+) create mode 100644 "khj20006/202507/09 BOJ G1 \354\204\234\353\241\234\354\206\214.md" diff --git "a/khj20006/202507/09 BOJ G1 \354\204\234\353\241\234\354\206\214.md" "b/khj20006/202507/09 BOJ G1 \354\204\234\353\241\234\354\206\214.md" new file mode 100644 index 00000000..d86516b9 --- /dev/null +++ "b/khj20006/202507/09 BOJ G1 \354\204\234\353\241\234\354\206\214.md" @@ -0,0 +1,114 @@ +```java +import java.util.*; +import java.io.*; + +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 A, B, N; + static List list; + + public static void main(String[] args) throws Exception { + + io = new IOController(); + + int TC = io.nextInt(); + for(int tc=1;tc<=TC;tc++) { + io.write("Case #" + tc + ": "); + init(); + solve(); + } + + io.close(); + + } + + public static void init() throws Exception { + + A = io.nextLong(); + B = io.nextLong(); + N = io.nextLong(); + + } + + static void solve() throws Exception { + + list = new ArrayList<>(); + for(long i=2;i*i<=N;i++) if(N%i == 0) { + while(N%i == 0) N/=i; + list.add(i); + } + if(N != 1) list.add(N); + + io.write((f(B) - f(A-1)) + "\n"); + + } + + static long f(long x) { + + long res = x; + int size = list.size(); + for(int i=1;i<(1<