一、可以直接调用math.factorial求得阶乘,然后算出组合数,如下:
import math
n,m = map(int,input().split())
print(math.factorial(n)//(math.factorial(m)*math.factorial(n-m)))
二、定义函数
def C(a, b):
res = 1
for i in range(a):
res *= b / a
b -= 1
a -= 1
return res
print(C(a,b))