728x90
반응형
11050번 이항 계수 1
문제풀이
#include <stdio.h>
#include <iostream>
using namespace std;
int get_value(int a)
{
int res = 1;
if (a < 0)
return 0;
else if (a > 1)
{
res = a * get_value(a - 1);
}
return res;
}
int main(void)
{
int n, k;
scanf("%d %d", &n, &k);
printf("%d", get_value(n) / (get_value(k) * get_value(n - k)));
}
팩토리얼을 재귀로 구현해보았다.
728x90
반응형
'자라는 개발자 > 문제풀이' 카테고리의 다른 글
백준 C++/C 2577번 숫자의 개수 (1) | 2021.12.27 |
---|---|
백준 C++ 1764번 듣보잡 (1) | 2021.12.26 |
백준 C++ 11651번 좌표정렬하기 2 (0) | 2021.12.22 |
백준 C++ 1654번 랜선 자르기 (0) | 2021.12.21 |
백준 C++ 10866번 덱 (1) | 2021.12.19 |