팩토리얼 값을 DP를 이용해서 저장한 다음 DP에 접근해 이항 계수를 출력하는 방식으로 코드를 작성했다.
💡코드(메모리 : 30944KB, 시간 : 36ms)
import sys
input= sys.stdin.readline
N, K =map(int,input().strip().split())
dp =[1]*(N+1)for i inrange(1, N+1):
dp[i]= i * dp[i-1]print((dp[N]//(dp[N-K]* dp[K]))%10007)