https://www.acmicpc.net/problem/11050
이항계수 공식만 알면 금방 구현할 수 있다.
팩토리얼을 main 내에서 하나하나 구하려면 코드가 너무 길어질 것 같아서 함수로 따로 만들어주었다.
#include <iostream>
using namespace std;
int fact(int a) {
int b = 1;
for (int i = 1; i <= a; i++) {
b *= i;
}
return b;
}
int main() {
int n, k;
cin >> n >> k;
int answer = fact(n) / (fact(k) * fact(n - k));
cout << answer << endl;
return 0;
}