Editorial for Tung xúc xắc


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.

Author: old_creator

Với \(n \ge 6\) ta có công thức truy hồi:

\(u_{n} = u_{n - 1} + u_{n - 2} + u_{n - 3} + u_{n - 4} + u_{n - 5} + u_{n - 6}\).

Và \(u_i = 2^{i - 1}\) với \(1 \le i \le 5\).

Từ đó ta có thể sử dụng phương pháp nhân ma trận và thuật toán lũy thừa nhanh để tính \(u_n\) trong \(log\:n\):

\(\begin{bmatrix} u_5\\ u_4\\ u_3\\ u_2\\ u_1\\ \end{bmatrix}\) \(*\) \(\begin{bmatrix} 1 & 1 & 0 & 0 & 0\\ 1 & 0 & 1 & 0 & 0\\ 1 & 0 & 0 & 1 & 0\\ 1 & 0 & 0 & 0 & 1\\ 1 & 0 & 0 & 0 & 0\\ \end{bmatrix}^n\) \(=\) \(\begin{bmatrix} u_{n + 5}\\ u_{n + 4}\\ u_{n + 3}\\ u_{n + 2}\\ u_{n + 1}\\ \end{bmatrix}\)


Comments

There are no comments at the moment.