๋ฐ์ํ
๐ค๋ฌธ์ ํด๊ฒฐ
-
D3 | dp? (ํผ๋ณด๋์น)
๐จ N = N-3 + N-2
๐ป์์ค ์ฝ๋
# ์ธํ
T = int(input())
Ns = [int(input()) for _ in range(T)]
# ํ์ด
# N-3 + N-2 = N, ํผ๋ณด๋์น๋ ๋น์ท, ์ซ์๊ฐ ๋์ฌ๋ ๋ง๋ค ๊ตฌํ๋ฉด ์๊ฐ์ด ์ค๋๊ฑธ๋ฆฌ๋ฏ๋ก ํ๋ฒ์ ๊ตฌํด๋๊ณ ํด๊ฒฐํ์.
pado = [1, 1, 1]
for i in range(3, 101): # N ์ ๋ฒ์๊ฐ 100 ๊น์ง
pado.append(pado[i - 3] + pado[i - 2])
# ๊ฒฐ๊ณผ ์ถ๋ ฅ
for tc in range(T):
print(f'#{tc + 1} {pado[Ns[tc] - 1]}')
๐๋ฌธ์ ํ์ธ
์ถ์ฒ: SW Expert Academy
๋ฐ์ํ
'Algorithm Problem > Python' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
[python] SWEA - 3750. Digit sum (0) | 2020.12.22 |
---|---|
[python] SWEA - 3408. ์ธ๊ฐ์ง ํฉ ๊ตฌํ๊ธฐ (0) | 2020.12.21 |
[python] SWEA - 3307. ์ต์ฅ ์ฆ๊ฐ ๋ถ๋ถ ์์ด (0) | 2020.12.19 |
[python] SWEA - 3304. ์ต์ฅ ๊ณตํต ๋ถ๋ถ ์์ด (0) | 2020.12.18 |
[python] SWEA - 3282. 0/1 Knapsack (0) | 2020.12.17 |