From abd4cf405fccffaa1ffbf0f58eb133b24874b576 Mon Sep 17 00:00:00 2001 From: naryeong-ko Date: Thu, 16 Jun 2022 21:35:03 +0900 Subject: [PATCH 1/2] =?UTF-8?q?220616=5Fsolve=20:=20=EC=B5=9C=EC=86=8C?= =?UTF-8?q?=EC=A7=81=EC=82=AC=EA=B0=81=ED=98=95=5Fko?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...54\202\254\352\260\201\355\230\225_ko.java" | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git "a/0616/Programmers/Lv1/\354\265\234\354\206\214\354\247\201\354\202\254\352\260\201\355\230\225_ko.java" "b/0616/Programmers/Lv1/\354\265\234\354\206\214\354\247\201\354\202\254\352\260\201\355\230\225_ko.java" index 8b13789..17cb6d5 100644 --- "a/0616/Programmers/Lv1/\354\265\234\354\206\214\354\247\201\354\202\254\352\260\201\355\230\225_ko.java" +++ "b/0616/Programmers/Lv1/\354\265\234\354\206\214\354\247\201\354\202\254\352\260\201\355\230\225_ko.java" @@ -1 +1,19 @@ +class Solution { + public int solution(int[][] sizes) { + int cLen = sizes.length; + int w = 0; + int h = 0; + for (int i = 0; i < cLen; i++) { + if (sizes[i][0] > sizes[i][1]) { + w = Math.max(w, sizes[i][0]); + h = Math.max(h, sizes[i][1]); + } else { + w = Math.max(w, sizes[i][1]); + h = Math.max(h, sizes[i][0]); + } + } + + return w * h; + } +} \ No newline at end of file From fdbfa0d1c34dd5683958d1244bbaed12385e31bc Mon Sep 17 00:00:00 2001 From: naryeong-ko Date: Thu, 16 Jun 2022 21:35:17 +0900 Subject: [PATCH 2/2] =?UTF-8?q?220616=5Fsolve=20:=20=EB=A9=80=EC=A9=A1?= =?UTF-8?q?=ED=95=9C=EC=82=AC=EA=B0=81=ED=98=95=5Fko?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...4\202\254\352\260\201\355\230\225_ko.java" | 24 +++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git "a/0616/Programmers/Lv2/\353\251\200\354\251\241\355\225\234\354\202\254\352\260\201\355\230\225_ko.java" "b/0616/Programmers/Lv2/\353\251\200\354\251\241\355\225\234\354\202\254\352\260\201\355\230\225_ko.java" index 8b13789..77976a8 100644 --- "a/0616/Programmers/Lv2/\353\251\200\354\251\241\355\225\234\354\202\254\352\260\201\355\230\225_ko.java" +++ "b/0616/Programmers/Lv2/\353\251\200\354\251\241\355\225\234\354\202\254\352\260\201\355\230\225_ko.java" @@ -1 +1,25 @@ +class Solution { + public long solution(int w, int h) { + int no; + if (w > h) + no = eucd(w, h); + else + no = eucd(h, w); + + return (long) w * h - (w + h - no); + } + + static int eucd(int big, int small) { // 유클리드호제법 + // 큰 숫자를 작은 숫자로 나눈 나머지 계산 + int r = big % small; + + // 나머지가 0이면 작은숫자가 최대공약수 + if (r == 0) + return small; + + // 나머지가 0 이상이면 더 찾기 + return eucd(small, r); + } + +}