-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathicpc11051.cpp
More file actions
25 lines (23 loc) · 773 Bytes
/
icpc11051.cpp
File metadata and controls
25 lines (23 loc) · 773 Bytes
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
#include <iostream>
#include <vector>
using namespace std;
int getBinomialCoefficient(int n, int k,
vector<vector<int> >& binomialCoefficient) {
int& value = binomialCoefficient[n][k];
if (value) return value;
if (k == 0 || k == n) return value = 1;
const int MOD = 10007;
return value = (getBinomialCoefficient(n - 1, k - 1, binomialCoefficient) +
getBinomialCoefficient(n - 1, k, binomialCoefficient)) %
MOD;
}
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
int n, k;
vector<vector<int> > binomialCoefficient(1001, vector<int>(1001));
cin >> n >> k;
cout << getBinomialCoefficient(n, k, binomialCoefficient);
return 0;
}