From ab5a6750191e39c691bc44851d93861f22697788 Mon Sep 17 00:00:00 2001 From: suyeun84 <81475092+suyeun84@users.noreply.github.com> Date: Sat, 27 Sep 2025 23:26:45 +0900 Subject: [PATCH] =?UTF-8?q?[20250927]=20PGM=20/=20LV2=20/=20=EB=A9=80?= =?UTF-8?q?=EC=A9=A1=ED=95=9C=20=EC=82=AC=EA=B0=81=ED=98=95=20/=20?= =?UTF-8?q?=EA=B9=80=EC=88=98=EC=97=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...4 \354\202\254\352\260\201\355\230\225.md" | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 "suyeun84/202509/27 PGM LV2 \353\251\200\354\251\241\355\225\234 \354\202\254\352\260\201\355\230\225.md" diff --git "a/suyeun84/202509/27 PGM LV2 \353\251\200\354\251\241\355\225\234 \354\202\254\352\260\201\355\230\225.md" "b/suyeun84/202509/27 PGM LV2 \353\251\200\354\251\241\355\225\234 \354\202\254\352\260\201\355\230\225.md" new file mode 100644 index 00000000..1043f3de --- /dev/null +++ "b/suyeun84/202509/27 PGM LV2 \353\251\200\354\251\241\355\225\234 \354\202\254\352\260\201\355\230\225.md" @@ -0,0 +1,22 @@ +```java +class Solution { + public long solution(int w, int h) { + long answer = (long)w * (long)h; + + long wl = (long)w / gcd(w, h); + long hl = (long)h / gcd(w, h); + + answer -= (wl + hl - 1) * gcd(w, h); + + return answer; + } + + //최대 공약수 (유클리드 호제법) + private static long gcd(long w, long h) { + if(h == 0) { + return w; + } + return gcd(h, w % h); + } +} +```