Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Реализация "сочетания" C(m,n) n<= 4009
- long long unsigned int Combination(const int m, const int n) {
- long long unsigned int fn = 1, dn = 1;
- const int nm = n - m;
- for (int i = 1; i <= n; i++) {
- if (i <= m)
- dn *= i;
- if (i > nm)
- fn *= i;
- if (fn % dn == 0) {
- fn /= dn;
- dn = 1;
- }
- }
- return fn / dn;
- }
Add Comment
Please, Sign In to add comment