Written by JS970
on
on
11050 - 이항 계수 1
- 난이도: 브론즈 1
- 날짜: 2023년 2월 7일
- 상태: Correct
- 추가 검토 여부: Yes
solution
- 이항계수를 구하는 문제이다. 이항계수란 $_nC_k$를 의미한다.
- 이항계수를 계산하기 위해서는 factorial연산을 필요로 한다.
- 직접 구현할 수도 있지만 cmath헤더파일의 tgamma함수를 이용하면 factorial을 쉽게 구할 수 있다.
- tgamma함수는 (인자-1)factorial을 출력한다.
code
#include <iostream>
#include <cmath>
using namespace std;
int main()
{
int N, K;
cin >> N >> K;
cout << tgamma(N+1) / (tgamma(K+1) * tgamma(N-K+1)) << endl;
return 0;
}