|
Algorithms_in_C++
1.0.0
Set of algorithms implemented in C++.
|
Class which contains all methods required for calculating nCr mod p. More...
Public Member Functions | |
| NCRModuloP (const uint64_t &size, const uint64_t &mod) | |
| the p from (nCr % p) More... | |
| uint64_t | gcdExtended (const uint64_t &a, const uint64_t &b, int64_t *x, int64_t *y) |
| int64_t | modInverse (const uint64_t &a, const uint64_t &m) |
| int64_t | ncr (const uint64_t &n, const uint64_t &r, const uint64_t &p) |
Private Attributes | |
| std::vector< uint64_t > | fac {} |
| uint64_t | p = 0 |
| stores precomputed factorial(i) % p value | |
Class which contains all methods required for calculating nCr mod p.
|
inline |
the p from (nCr % p)
Constructor which precomputes the values of n! % mod from n=0 to size and stores them in vector 'fac' @params[in] the numbers 'size', 'mod'
|
inline |
Finds the value of x, y such that a*x + b*y = gcd(a,b)
@params[in] the numbers 'a', 'b' and address of 'x' and 'y' from above equation
|
inline |
Find modular inverse of a with m i.e. a number x such that (a*x)m = 1
@params[in] the numbers 'a' and 'm' from above equation
|
inline |
Find nCr % p
@params[in] the numbers 'n', 'r' and 'p'