[Programmers] 카펫

Time Lapse :NONE

solution.cpp

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
#include <string>
#include <vector>

using namespace std;

vector<int> solution(int brown, int red) {
int cell = brown+red;
for(int y=3;y<cell/2;y++){
if(cell%y==0&&((2*y+2*(cell/y)-4)==brown)){
vector<int> answer;
answer.push_back(cell/y);
answer.push_back(y);
return answer;
}
}
}
Author: Song Hayoung
Link: https://songhayoung.github.io/2020/07/30/PS/Programmers/carpet/
Copyright Notice: All articles in this blog are licensed under CC BY-NC-SA 4.0 unless stating additionally.