Skip to content

Commit 00cfaee

Browse files
committed
docs: [PGS] 카펫에 대한 다른 사람 풀이도 코드에 추가
1 parent 23fa42a commit 00cfaee

File tree

1 file changed

+24
-1
lines changed

1 file changed

+24
-1
lines changed

minjeong/BruteForce/2024-05-07-[PGS]-#카펫.py

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,27 @@ def solution(brown, yellow):
77

88
if (2*w + 2*h - 4 == brown) and ((w-2)*(h-2) == yellow): # 조건에 해당하는지 확인
99
return [max(w, h), min(w,h)]
10-
10+
11+
# # 다른 풀이 1
12+
# def solution(brown, yellow):
13+
# for i in range(1, int(yellow**(1/2))+1):
14+
# if yellow % i == 0:
15+
# if 2*(i + yellow//i) == brown-4:
16+
# return [yellow//i+2, i+2]
17+
18+
# # 다른 풀이2
19+
# import math
20+
# def solution(brown, yellow):
21+
# w = ((brown+4)/2 + math.sqrt(((brown+4)/2)**2-4*(brown+yellow)))/2
22+
# h = ((brown+4)/2 - math.sqrt(((brown+4)/2)**2-4*(brown+yellow)))/2
23+
# return [w,h]
24+
25+
# # 다른 풀이 3
26+
# def solution(brown, yellow):
27+
# nm = brown + yellow
28+
# for n in range(1, nm+1):
29+
# if nm%n != 0:
30+
# continue
31+
# m = nm//n
32+
# if (n-2)*(m-2) == yellow:
33+
# return sorted([n, m], reverse = True)

0 commit comments

Comments
 (0)