第三题题解,组合问题
#
#
# @param n int整型 乐谱总音符数
# @param m int整型 重音符数
# @param k int整型 重音符之间至少的间隔
# @return long长整型
#
import math
class Solution:
def solve_bangbang(self , n , m , k ):
# write code here
TotalMusic = n-m-(m-1)*k;
ToChose = m;
if TotalMusic<=0:
return 0
X = ToChose
Y = TotalMusic+1
a = X+Y-1
b = Y-1
res = math.factorial(a)//(math.factorial(a-b)*math.factorial(b))
return res%1000000007
京公网安备 11010502036488号