Skip to content

Commit 64fdf7a

Browse files
committed
[Level II] 노란 격자의 각 가로/세로 길이 case에서의 격자 배치에 따른 갈색 격자의 배치를 계산하여, 격자의 개수를 비교
1 parent a41cfae commit 64fdf7a

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

브루트 포스/카펫.cpp

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
#include <string>
2+
#include <vector>
3+
#include <iostream>
4+
using namespace std;
5+
6+
vector<int> solution(int brown, int yellow) {
7+
vector<int> answer;
8+
9+
for (int yw=1; yw<=yellow; yw++) {
10+
if (yellow%yw == 0) {
11+
int yh = yellow / yw;
12+
int bw = yw + 2;
13+
int bh = yh + 2;
14+
if (bw*bh - yw*yh == brown) {
15+
answer.push_back(bh);
16+
answer.push_back(bw);
17+
break;
18+
}
19+
}
20+
}
21+
return answer;
22+
}

0 commit comments

Comments
 (0)