Programming/Python & Data Structures
[Baekjoon/Python3] 11050번 이항 계수 1
HooNeee
2020. 12. 7. 00:19
[Baekjoon/Python3] 11050번 이항 계수 1
11050번: 이항 계수 1
첫째 줄에 \(N\)과 \(K\)가 주어진다. (1 ≤ \(N\) ≤ 10, 0 ≤ \(K\) ≤ \(N\))
www.acmicpc.net
# math 모듈 - factoral() 함수 사용시
import math
n, k = map(int, input().split())
print(int(math.factorial(n) / (math.factorial(k) * (math.factorial(n - k)))))
# factorial() 함수 구현
def factorial(a):
res = 1
for i in range(1, a + 1):
res *= i
return res
n, k = map(int, input().split())
print(int(factorial(n) / (factorial(k) * (factorial(n - k)))))