教學上機考第四題題解
不要笑←不要笑↓不要笑→
題目
兎田ぺこら的笑聲有各式各樣的方向(共8個方向),但是總有個笑聲的規律,他想知道自己在特定長度的笑聲有幾種組法。
現在ぺこら想找你寫一隻程式,請你計算在時長為n的時候有幾種笑法。考慮到答案可能很大,故請將結果模1e9+7輸出。
笑聲規律:↗ +↘總共的數量為偶數,↑和↓的數量總和為奇數個
笑聲有八種方向
↗ +↘為偶數,↑+↓為奇數
求滿足條件且排列長度為n的方法數
簡單來說
subtask1-2
DP
DP
定義狀態
初始狀態
DP
導出轉移
subtask1-2
50分
subtask3
快速冪
矩陣乘法
改寫遞迴式
矩陣快速冪