

가로 = total/i
세로 = i
class Solution {
public int[] solution(int brown, int yellow) {
int[] answer = new int[2];
//전체 타일 수
int total = brown + yellow;
//카펫의 최소 길이는 3이라 3부터 시작
for (int i = 3; i <= total / i; i++) {
if (total % i == 0) {
int row = total / i;
int col = i;
// 주어진 brown, yellow 수와 일치하는지 확인
if ((row - 2) * (col - 2) == yellow) {
answer[0] = row;
answer[1] = col;
break;
}
}
}
return answer;
}
}
https://school.programmers.co.kr/learn/courses/30/lessons/42842