import java.util.*;
class p카펫 {
public int[] solution(int brown, int yellow) {
int[] answer = {0,0};
int totalSum = brown+yellow;
Map<Integer,Integer> m = new HashMap<>();
for(int i = 3 ; i <= totalSum/2; i++ ){
if(totalSum%i == 0){
if(((totalSum/i*2)+(i*2)-4) == brown){
answer[0] = i;
answer[1] = totalSum/i;
}
}
}
return answer;
}
}
'Algorithm > Programers' 카테고리의 다른 글
Lv 2. 예상대진표 (0) | 2024.05.22 |
---|---|
Lv 2. N개의 최소공배수 (0) | 2024.04.19 |
Lv 2. 짝지어 제거하기 (0) | 2024.04.17 |
Lv 2. 다음 큰 숫자 (0) | 2024.04.15 |
Lv 2. 피보나치 수 (0) | 2024.04.10 |