728x90 멀쩡한 사각형1 멀쩡한 사각형 (자바) package prog; public class 멀쩡한_사각형 { public static void main(String[] args) { Solution_멀쩡한_사각형 s = new Solution_멀쩡한_사각형(); System.out.println(s.solution(8,12)); System.out.println(s.solution(2,3)); } } class Solution_멀쩡한_사각형{ public long solution(int w, int h) { long answer = 1; answer=(long)w*h - (w+h-gcd(w,h)); return answer; } public static int gcd(int a, int b) { while(b!=0){ int r = a%b; a=.. 2021. 9. 6. 이전 1 다음 728x90