From 2d6f3752950074e4b826c18170e6d8f76b030624 Mon Sep 17 00:00:00 2001 From: zinnnn37 Date: Wed, 25 Feb 2026 23:02:50 +0900 Subject: [PATCH] =?UTF-8?q?[20260225]=20BOJ=20/=20G5=20/=20=EA=B3=B5?= =?UTF-8?q?=EC=95=BD=EC=88=98=20/=20=EA=B9=80=EB=AF=BC=EC=A7=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...5 \352\263\265\354\225\275\354\210\230.md" | 56 +++++++++++++++++++ 1 file changed, 56 insertions(+) create mode 100644 "zinnnn37/202602/25 BOJ G5 \352\263\265\354\225\275\354\210\230.md" diff --git "a/zinnnn37/202602/25 BOJ G5 \352\263\265\354\225\275\354\210\230.md" "b/zinnnn37/202602/25 BOJ G5 \352\263\265\354\225\275\354\210\230.md" new file mode 100644 index 00000000..00f4bbb3 --- /dev/null +++ "b/zinnnn37/202602/25 BOJ G5 \352\263\265\354\225\275\354\210\230.md" @@ -0,0 +1,56 @@ +```java +import java.io.*; +import java.util.StringTokenizer; + +public class BJ_2436_공약수 { + + private static final BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); + private static final BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out)); + private static StringTokenizer st; + + private static int gcd, lcm; + private static long resA, resB; + + public static void main(String[] args) throws IOException { + init(); + sol(); + } + + private static void init() throws IOException { + st = new StringTokenizer(br.readLine()); + gcd = Integer.parseInt(st.nextToken()); + lcm = Integer.parseInt(st.nextToken()); + } + + private static void sol() throws IOException { + long div = lcm / gcd; + + for (int i = 1; i <= Math.sqrt(div); i++) { + if (div % i == 0) { + long a = i; + long b = div / i; + + if (gcd(a, b) == 1) { + resA = a; + resB = b; + } + } + } + bw.write((resA * gcd) + " " + (resB * gcd)); + bw.flush(); + bw.close(); + br.close(); + } + + private static long gcd(long a, long b) { + while (b != 0) { + long tmp = b; + b = a % b; + a = tmp; + } + + return a; + } + +} +``` \ No newline at end of file