๋ฌธ์
https://www.acmicpc.net/problem/11057
ํ์ด
# ๋ฐฑ์ค 11057๋ฒ ๋ฌธ์ - ์ค๋ฅด๋ง ์
n = int(input())
dp = [1]*10
for i in range(1,n) :
for j in range(1,10) :
dp[j] += dp[j-1]
print(sum(dp)%10007)
DP ๋ฌธ์ ์ด๋ค.
i ์๋ฆฌ ์ \ j | 0์ผ๋ก ๋๋๋ ์ซ์ | 1 | 2 | 3 | 4 | 5 |
n = 1 | 1 | 1 | 1 | 1 | 1 | 1 |
n = 2 | 1 | 2 | 3 | 4 | 5 | 6 |
n = 3 | 1 | 3 | 6 | 10 | 15 | 21 |
์์ ๊ฐ์ ํ๋ฅผ ๊ตฌํ ์ ์๋ค. ์ด๋ฅผ ์ ํ์์ผ๋ก ๋ฐ๊พธ๋ฉด
dp[j] = dp[j] + dp[j-1]
์ด๋ ๊ฒ ๋๋ค.
'๐๏ธ Algorithm > ๐ฉ ๋ฐฑ์ค' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
๐ฉ [๋ฐฑ์ค] [Python] [Gold3] 2252๋ฒ_์ค ์ธ์ฐ๊ธฐ (1) | 2023.05.04 |
---|---|
๐ฉ [๋ฐฑ์ค] [Python] [Gold5] 2096๋ฒ_๋ด๋ ค๊ฐ๊ธฐ (2) | 2023.05.03 |
๐ฉ [๋ฐฑ์ค] [Python] [Gold5] 17070๋ฒ_ํ์ดํ ์ฎ๊ธฐ๊ธฐ 1 (0) | 2023.05.01 |
๐ฉ [๋ฐฑ์ค] [Python] [Gold5] 2470๋ฒ_๋ ์ฉ์ก (0) | 2023.04.30 |
๐ฉ [๋ฐฑ์ค] [Python] [Gold5] 2565๋ฒ_์ ๊น์ค (0) | 2023.04.29 |