What I Learned/Algorithm Practice
[백준 - python] 11050번: 이항 계수 1
Interrobang
2022. 11. 25. 20:11
문제 링크
11050번: 이항 계수 1
첫째 줄에 \(N\)과 \(K\)가 주어진다. (1 ≤ \(N\) ≤ 10, 0 ≤ \(K\) ≤ \(N\))
www.acmicpc.net
문제 풀이
from math import factorial
n, k = map(int, input().split())
print(factorial(n) // (factorial(k) * factorial(n - k)))

*key point: math 라이브러리의 factorial 함수를 활용한다. 이항 계수는 아래의 공식으로 구해진다.
