๋ฌธ์ ๋งํฌ
https://www.acmicpc.net/problem/11051
์ฝ๋ ์ ์ถ ๊ธฐ๋ก (๋ฉ๋ชจ๋ฆฌ ๋ฐ ์๊ฐ)
์ ์ถ ๋ ์ง
@4/23/2021
๋ฉ๋ชจ๋ฆฌ
204292 KB
์๊ฐ
268 ms
๋ฉ๋ชจ
โข
๋ฌธ์ ํ์ด
k ๊ฐ 0 ์ผ๋! ๋นผ๋จน์ง ์์ ๊ฒ!!
Code
์ฌ๊ท๋ก ํธ๋๊น ์๊ฐ์ด๊ณผ๋จ...ใ
N, K = map(int, input().split())
def recursion(n, k):
if n == k:
return 1
if k == 1:
return n
return recursion(n-1, k-1) + recursion(n-1, k)
print(recursion(N, K))
Python
๋ณต์ฌ
์ ์ถ ๋ ์ง
@4/23/2021
๋ฉ๋ชจ๋ฆฌ
204292 KB
์๊ฐ
268 ms
N, K = map(int, input().split())
dp = [[0 for _ in range(N+1)] for _ in range(N+1)]
for i in range(0, N+1):
for j in range(0, N+1):
if j == 0:
dp[i][j] = 1
elif i == j:
dp[i][j] = 1
elif j == 1:
dp[i][j] = i
elif N >= K:
dp[i][j] = dp[i-1][j-1] + dp[i-1][j]
print(dp[N][K] % 10007)
Python
๋ณต์ฌ