Algorithm [C++]/Programmers [Level2]
[완전 탐색] 카펫
뮤링이
2022. 6. 28. 01:33
#include <string>
#include <vector>
#include <cmath>
using namespace std;
vector<int> solution(int brown, int yellow) {
vector<int> answer;
for(int h=1; h<=sqrt(brown+yellow);h++){
if((brown+yellow)%h==0){
int w=(brown+yellow)/h;
if((w-2) * (h-2)==yellow){
return vector<int>{w, h};
}
}
}
}