개인공부/코딩테스트
백준 11050번: 이항 계수1/ C++
Itsumo
2023. 2. 6. 21:27
https://www.acmicpc.net/problem/11050
11050번: 이항 계수 1
첫째 줄에 \(N\)과 \(K\)가 주어진다. (1 ≤ \(N\) ≤ 10, 0 ≤ \(K\) ≤ \(N\))
www.acmicpc.net
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
|
#include <iostream>
using namespace std;
int Factorial(int num)
{
if(num == 0)
return 1;
int Result = 1;
while(num != 1)
{
Result *= num--;
}
return Result;
}
int main()
{
int N, K;
cin >> N >> K;
int Output = (Factorial(N)/Factorial(K))/Factorial(N-K);
cout << Output;
return 0;
}
|
cs |