You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
用前面i-1的个数推到ith的个数classSolution:
defcountVowelPermutation(self, n: int) ->int:
''' a - > e e - > a i i - > a , e , u , o o - > i,u u - > a 转过来 a e i o u a,0 <- 1,2,4 e 1<- 0,2 '''mod=10**9+7f= [[0] *5for_inrange(n)]
f[0] = [1,1,1,1,1]
foriinrange(1, n):
f[i][0] = (f[i-1][1]+f[i-1][2] +f[i-1][4])%modf[i][1] = (f[i-1][0] +f[i-1][2])%modf[i][2] = (f[i-1][1] +f[i-1][3])%modf[i][3] = (f[i-1][2])%modf[i][4] = (f[i-1][2] +f[i-1][3])%modreturnsum(f[-1]) %mod