728x90
import math
def solution(brown, red):
answer = []
sq_red=int(math.sqrt(red))
a,b=0,0
for num in range(1,sq_red+1):
flt_rv=red/num
int_rv=red//num
if flt_rv==int_rv:
flt_bv=(brown+red)/(int_rv+2)
int_bv=(brown+red)//(int_rv+2)
if flt_bv==int_bv:
b=int_bv
a=(brown+red)//b
answer=[a,b]
return answer
'STUDY > Algorithm' 카테고리의 다른 글
[프로그래머스] LEVEL2 올바른 괄호, python3 (0) | 2020.01.07 |
---|---|
[프로그래머스] 2020카카오공채 괄호 변환, python3 (0) | 2020.01.02 |
[프로그래머스] LEVEL2 타겟 넘버, python3, 깊이/너비 우선 탐색(DFS/BFS) (0) | 2019.11.20 |
[프로그래머스] LEVEL2 멀쩡한 사각형,python3, 서머코딩/윈터코딩(2019) (0) | 2019.11.19 |
[프로그래머스] LEVEL2 위장, python3, 해시 (0) | 2019.11.18 |