Skip to content

Commit 23fa42a

Browse files
committed
[PGS] 카펫 / Level 2 / 40분(성공)
1 parent a12bf01 commit 23fa42a

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
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)]
10+

0 commit comments

Comments
 (0)