반응형
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <stack>
#include <vector>
#include <math.h>
#include <queue>
using namespace std;
// 5C3 = 4C2 + 4C3
int dy[21][21];
int DFS(int n, int r){
if(dy[n][r]>0) return dy[n][r];
if(r==0 || n==r) return 1;
else{
return dy[n][r] = DFS(n-1, r-1) + DFS(n-1, r);
}
}
int main() {
//freopen("input.txt.txt","rt",stdin);
int n, r;
scanf("%d %d", &n, &r);
printf("%d", DFS(n,r));
return 0;
}
반응형
'Algorithm > etc' 카테고리의 다른 글
크루스칼 알고리즘 Kruskal MST(최소스패닝트리) (0) | 2022.01.18 |
---|---|
DFS , dis-joint set (Union & Find 알고리즘) (0) | 2022.01.18 |
priority queue와 struct vector을 이용한 정렬 (0) | 2022.01.17 |
C++ 구조체 만들기 (0) | 2022.01.17 |
priority_queue : 우선순위 큐 , 최소힙, 최대힙 (0) | 2022.01.17 |