Skip to content

Commit 83b258a

Browse files
committed
95차 3번 문제 풀이
1 parent bbd2ae8 commit 83b258a

1 file changed

Lines changed: 26 additions & 0 deletions

File tree

live9/test95/문제3/박희경.py

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# 처음 푼 풀이
2+
from itertools import *
3+
4+
def solution(brown, yellow):
5+
answer = []
6+
yellow_list = set()
7+
if yellow == 1: yellow_list.add(1)
8+
for i in range(1, yellow // 2 + 1):
9+
if yellow % i == 0:
10+
yellow_list.add(i)
11+
yellow_list.add(yellow // i)
12+
13+
for x, y in product(yellow_list, repeat=2):
14+
if x * y == yellow and x >= y:
15+
if x * 2 + y * 2 + 4 == brown:
16+
answer.append(x + 2)
17+
answer.append(y + 2)
18+
19+
return answer
20+
21+
# 다른 풀이 보니 중복 순열을 굳이 쓸 필요 없음
22+
def solution(brown, yellow):
23+
for i in range(1, int(yellow ** 0.5) + 1):
24+
if yellow % i == 0:
25+
if (i + yellow // i) * 2 == brown - 4:
26+
return [yellow // i + 2, i + 2]

0 commit comments

Comments
 (0)