Editorial for HOCKEY GAME


Remember to use this editorial only when stuck, and not to copy-paste code from it. Please be respectful to the problem author and editorialist.

Submitting an official solution before solving the problem yourself is a bannable offence.

Đây là một bài toán Quy hoạch động.

Gọi \(F_i\) là số cách nhảy để vượt qua đoạn đường dài \(i\) mét.

Ta có cơ sở quy hoạch động:

\(F_0 = 1\)

\(F_1 = 1\)

\(F_2 = 2\)

Công thức truy hồi:

\(F_i = F_{i-1} \% M + F_{i -2} \% M + F_{i-3} \% M\)

Kết quả cần tìm là \(F_n \% M\)

  • Subtask 1 và Subtask 2: Tính lần lượt các giá trị \(F_3,F_4,...,F_n\). Độ phức tạp \(O(n)\)
  • Subtask 3: Sử dụng nhân ma trận.


Comments

There are no comments at the moment.