알고리즘
[알고리즘] c++ cpp 카펫
keel_im
2020. 10. 23. 19:49
반응형
포인트
1. 머리를 조금 굴릴 필요가 있다.
🧶문서는 항상 수정 될 수 있습니다. 비판은 환영합니다.
#include <string>
#include <vector>
using namespace std;
vector<int> solution(int brown, int yellow) {
vector<int> answer;
for(int i = yellow ; i >= (yellow/i) ; i--){
if (yellow%i != 0) {
continue;
}
if (((2*i)+(2*(yellow/i))+4) == brown) {
answer.push_back(i+2);
answer.push_back((yellow/i)+2);
break;
}
}
return answer;
}
반응형