diff --git "a/LeetCode/1211-1220/1220. \347\273\237\350\256\241\345\205\203\351\237\263\345\255\227\346\257\215\345\272\217\345\210\227\347\232\204\346\225\260\347\233\256\357\274\210\345\233\260\351\232\276\357\274\211.md" "b/LeetCode/1211-1220/1220. \347\273\237\350\256\241\345\205\203\351\237\263\345\255\227\346\257\215\345\272\217\345\210\227\347\232\204\346\225\260\347\233\256\357\274\210\345\233\260\351\232\276\357\274\211.md" index 224e8b69..31467f6b 100644 --- "a/LeetCode/1211-1220/1220. \347\273\237\350\256\241\345\205\203\351\237\263\345\255\227\346\257\215\345\272\217\345\210\227\347\232\204\346\225\260\347\233\256\357\274\210\345\233\260\351\232\276\357\274\211.md" +++ "b/LeetCode/1211-1220/1220. \347\273\237\350\256\241\345\205\203\351\237\263\345\255\227\346\257\215\345\272\217\345\210\227\347\232\204\346\225\260\347\233\256\357\274\210\345\233\260\351\232\276\357\274\211.md" @@ -45,7 +45,7 @@ Tag : 「线性 DP」、「矩阵快速幂」 --- -## 线性 DP +### 线性 DP **定义 $f[i][j]$ 为考虑长度为 $i + 1$ 的字符串,且结尾元素为 $j$ 的方案数(其中 $j$ 代表数组 `['a', 'e', 'i', 'o', 'u']` 下标)。** @@ -116,7 +116,8 @@ class Solution { } ``` - -```Python3 + +```Python MOD = int(1e9) + 7 class Solution: def countVowelPermutation(self, n: int) -> int: @@ -130,6 +131,7 @@ class Solution: return (((((f[-1][0] + f[-1][1]) % MOD + f[-1][2]) % MOD + f[-1][3]) % MOD) + f[-1][4]) % MOD ``` - + ```Go const MOD int = 1e9 + 7 func countVowelPermutation(n int) int { @@ -363,7 +365,7 @@ class Solution { } ``` - -```Python3 +```python import numpy as np MOD = 10 ** 9 + 7 dtype = np.dtype('uint64')