알고리즘

C++ 알고리즘 - 백준 11050 이항 계수 1

마루설아 2024. 12. 28. 21:55

https://www.acmicpc.net/problem/11050

 

#include <iostream>
#define endl "\n"

using namespace std;

int fact(int n) {
	if (n == 0) return 1;
	if (n == 1) return 1;
	return n * fact(n - 1);
}

int main(void) {
	// C++ Init
	ios::sync_with_stdio(false);
	cin.tie(NULL);

	int input1, input2;

	cin >> input1 >> input2;
	cout << fact(input1) / (fact(input1-input2) * fact(input2)) << endl;
}