1. Problem
2. Others' Solutions
import sys
n,k = map(int,sys.stdin.readline().rstrip().split())
dp = [[0]*(k+1) for _ in range(n+1)]
const = 1000000000
for i in range(n+1):
dp[i][1] = 1
for j in range(2,k+1):
for i in range(0,n+1):
for q in range(i+1):
dp[i][j] += (dp[q][j-1] % const)
print(dp[n][k] % const)
dp[n][k] = (dp[n-1][k] + dp[n][k-1]) % const
3. Learned
1. Problem
2. My Solution
import sys
test_n = int(sys.stdin.readline().rstrip())
dp = [0] * 1000001
dp[1] = 1
dp[2] = 2
dp[3] = 4
for i in range(4,1000001):
dp[i] = (dp[i-3] + dp[i-2] + dp[i-1]) % 1000000009
for _ in range(test_n):
n = int(sys.stdin.readline().rstrip())
print(dp[n] % 1000000009)