Home > other >  The frog jumped the steps
The frog jumped the steps

Time:09-15

Have what problem, ask me this method basically no problem when n is small, several big up then there is something wrong with the
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 complicated

CodePudding user response:

It's not complicated, is not a problem of permutation and combination

CodePudding 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])
  • Related