
#include <string>
#include <vector>
#include <algorithm>
using namespace std;
bool check(int b, int y, int w, int h){
    if(h < 3) return false;
    // 들어온 w와 h가 brown과 yellow의 조건을 만족하는지를 찾는 부분
    if((2*w + (h-2)*2) == b) return true;
    return false;
}
vector<int> solution(int brown, int yellow) {
    vector<int> answer;
    int whole = brown+yellow;
    // height는 반드시 3이상이므로 i=3부터 시작하며, whole/3까지만 반복하면 된다. 
    for(int i=3; i<=whole/3; i++){
        if((whole % i) == 0){
            if(check(brown, yellow, i, whole/i)){
                answer.push_back(whole/i);
                answer.push_back(i);
                break;
            }
        }
    }
    return answer;
}if((2*w + (h-2)*2) == b) return true; 단순한 조건이지만 이렇게 수학적으로 해결하는 부분이 좋았다.