Skip to content

Commit

Permalink
Create comb.cpp
Browse files Browse the repository at this point in the history
  • Loading branch information
wisdompeak authored Nov 1, 2020
1 parent 4dea701 commit 9f5d4d5
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions Template/Combination-Number/comb.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
typedefine long long ll;

main()
{
// compute all C(n,m) saved in comb
ll comb[1000][1000];
for (int i = 0; i <= n; ++i)
{
comb[i][i] = comb[i][0] = 1;
for (int j = 1; j < i; ++j)
{
comb[i][j] = comb[i - 1][j - 1] + C[i - 1][j];
}
}
}

// Compute C(n,m) on demand
ll help(int n, int m)
{
long long cnt = 1;
for(int i = 0; i < m; i++)
{
cnt *= n - i;
cnt /= i + 1;
}
return cnt;
}

0 comments on commit 9f5d4d5

Please sign in to comment.