목록comb (1)
호기심 많은 분석가

11050번: 이항 계수 1 첫째 줄에 N과 K가 주어진다. (1 ≤ N ≤ 10, 0 ≤ K ≤ N) www.acmicpc.net 크게 어려운 문제는 아니었지만 독특했다. math의 comb라는 combination 개수를 뽑아주는 함수가 있는데, 그 함수를 사용하면 런타임 에러가 발생한다. 그래서 간단하게 factorial로 구현해줬다. import math import sys n, k = map(int, sys.stdin.readline().split()) ans = math.factorial(n)/(math.factorial(k)*math.factorial(n-k)) print(ans)
Coding/Coding Test & Algorithm
2021. 6. 2. 13:08