매일 C++ day 6

2021-05-24

카펫

https://programmers.co.kr/learn/courses/30/lessons/42842

#include <string>
#include <vector>

using namespace std;

vector<int> solution(int brown, int yellow) {
    vector<int> answer;
    int count = brown + yellow;
    int width, height;
    /*
        2w+2h - 4 = brown;
        wxh = count
    */
    for(height = 3; height < 2500; height++) 
    {
        width = brown*0.5 + 2 - height;
        if(width*height==count) 
        {
            answer.push_back(width);
            answer.push_back(height);
            break;
        }
    }    
    return answer;
}

test test