1. Title:
2. Solution:
The class Solution:
Def numWays (self, n: int) - & gt; Int:
Steps=int (n/2)
Nums=0
For step in range (+ 1) steps:
Tstep=n - step * 2 + step
Nums +=self. C (tstep, step)
Return int (nums % 1000000007)
Def c (self, n, m) :
"" "
O combinations of
"" "
Return int (math) factorial (n)/(math) factorial (m) * math.h factorial (n, m))) % 1000000007
CodePudding user response:
Not (n - 1) + (n - 2) number? Why so complicatedCodePudding user response:
It's not complicated, is not a problem of permutation and combinationCodePudding user response:
Is this meaning?def f (n) :
L=[0, 1]
For I in range (1, n + 1) :
L=[l [1], the sum (l)]
Return the l
Print (f (7) [1])