Algorithms
백준 11051. 이항 계수 2
Brian Go
2022. 6. 11. 22:15
https://www.acmicpc.net/problem/11051
11051번: 이항 계수 2
첫째 줄에 \(N\)과 \(K\)가 주어진다. (1 ≤ \(N\) ≤ 1,000, 0 ≤ \(K\) ≤ \(N\))
www.acmicpc.net
문제 자체는 바로 이전 문제와 거의 동일하나, 결과를 10,007로 나눈 나머지를 구해주면 된다.
import math
n, k = map(int, input().split())
res = math.factorial(n)//(math.factorial(n-k) * math.factorial(k))
print(res % 10007)