MCPcopy Create free account
hub / github.com/SuprDewd/CompetitiveProgramming / nck

Function nck

code/mathematics/nck.cpp:1–6  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1int nck(int n, int k) {
2 if (n < k) return 0;
3 k = min(k, n - k);
4 int res = 1;
5 rep(i,1,k+1) res = res * (n - (k - i)) / i;
6 return res; }
7int nck(int n, int k, int p) {
8 int res = 1;
9 while (n || k) {

Callers 1

testFunction · 0.85

Calls

no outgoing calls

Tested by 1

testFunction · 0.68