Skip to content

Commit c6c2522

Browse files
committed
[PGS] 카펫 / Level 2 / 15분 / 성공
1 parent a3ce78a commit c6c2522

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
def solution(brown, yellow):
2+
carpet_size = brown + yellow # 카펫의 전체 크기
3+
4+
for w in range(1,int(carpet_size**0.5)+1): # 약수 범위 설정. 여기서 w는 너비를 의미함
5+
if carpet_size % w == 0: # 약수라면
6+
h = carpet_size // w # 전체 크기에서 너비로 나눈 값을 높이로 설정
7+
8+
if (2*w + 2*h - 4 == brown) and ((w-2)*(h-2) == yellow): # 조건에 해당하는지 확인
9+
return [max(w, h), min(w, h)]

0 commit comments

Comments
 (0)