Merged in DR v1.0.0.2
This commit is contained in:
10
Utils.py
10
Utils.py
@@ -1,12 +1,11 @@
|
||||
#!/usr/bin/env python3
|
||||
import os
|
||||
import re
|
||||
import operator as op
|
||||
import subprocess
|
||||
import sys
|
||||
import xml.etree.ElementTree as ET
|
||||
from collections import defaultdict
|
||||
from functools import reduce
|
||||
from math import factorial
|
||||
from itertools import count
|
||||
|
||||
|
||||
@@ -133,12 +132,9 @@ def kth_combination(k, l, r):
|
||||
|
||||
|
||||
def ncr(n, r):
|
||||
if r == 0:
|
||||
if r == 0 or r >= n:
|
||||
return 1
|
||||
r = min(r, n-r)
|
||||
numerator = reduce(op.mul, range(n, n-r, -1), 1)
|
||||
denominator = reduce(op.mul, range(1, r+1), 1)
|
||||
return numerator / denominator
|
||||
return factorial(n) // factorial(r) // factorial(n-r)
|
||||
|
||||
|
||||
entrance_offsets = {
|
||||
|
||||
Reference in New Issue
Block a user