Skip to content

Commit 1c81cf2

Browse files
author
hangyeol
committed
95차 3번 문제풀이
1 parent 9706c51 commit 1c81cf2

1 file changed

Lines changed: 31 additions & 0 deletions

File tree

live9/test95/문제3/백한결.py

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
import itertools
2+
3+
4+
def solution(brown, yellow):
5+
answer = []
6+
pair = []
7+
8+
total = brown + yellow
9+
10+
divisors = getDivisor(total)
11+
12+
for comb in itertools.product(divisors, repeat=2):
13+
if (comb[0] - 2) * (comb[1] - 2) == yellow and comb[0] >= comb[1]:
14+
pair.append(comb)
15+
16+
pair.sort(reverse=True)
17+
18+
answer.append(pair[0][0])
19+
answer.append(pair[0][1])
20+
21+
return answer
22+
23+
24+
def getDivisor(num):
25+
divisors = []
26+
27+
for i in range(1, num + 1):
28+
if num % i == 0:
29+
divisors.append(i)
30+
31+
return divisors

0 commit comments

Comments
 (0)