[ํ๋ก๊ทธ๋๋จธ์ค] LV.2 ์นดํซ
brown yellow ๊ฐ๊ฐ์ด ์ฃผ์ด์ง๊ณ
๊ฐ๋ก์ธ๋ก ๊ธธ์ด ๊ตฌํ๋ ๋ฌธ์
2. ํ์ด
yellow๊ฐ ๋ฐ๊นฅ ์ฌ๊ฐํ์ ๊ฐ๋ก-2, ์ธ๋ก-2๊ฐ ๋๋ ๊ท์น์ ์ฐพ์ ์ ์์ด์ผํ๋ค.
3. ์ฝ๋
def solution(brown, yellow):
s = brown + yellow
for i in range(s, 2, -1):
if s % i == 0:
a = s//i
if yellow == (i-2) * (a-2):
return [i, a]
'๐ป Coding Problems Solving > Brute Force' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
[BOJ 1992] ์ฟผ๋ํธ๋ฆฌ (0) | 2023.06.26 |
---|---|
[BOJ 16637] ๊ดํธ์ถ๊ฐํ๊ธฐ (0) | 2023.06.22 |
[BOJ 12919] A์ B2 (0) | 2023.06.18 |
[BOJ 3085] ์ฌํ๊ฒ์ (0) | 2022.06.26 |
[BOJ 2309] ์ผ๊ณฑ ๋์์ด (0) | 2022.06.21 |
์ต๊ทผ๋๊ธ