#include <string>
#include <vector>
#include <iostream>
using namespace std;
vector<int> sort(vector<int>a){
    int tmp = 0;
    for(int i = 0; i < a.size() - 1 ; i++){
        for(int j = i + 1; j < a.size(); j++){
            if(a[i] < a[j]){
                tmp = a[i];
                a[i] = a[j];
                 a[j] = tmp;
            }
        }
    }
    return a;
}
vector<int> solution(int brown, int red) {
    vector<int> answer;
    
    int total = brown + red;
    int wid = 0, hei = 0;
    for(int i=3; i < total/2; i++){
        if(total % i == 0 ){
            wid = i;
            hei = total / i;
            if((wid-2) * ( hei - 2) == red){
                answer.push_back(wid);
                answer.push_back(hei);
                break;
            }
        }
    }
    answer = sort(answer);
    return answer;
}

+ Recent posts