Editorial for Forever Alone Person
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.
Submitting an official solution before solving the problem yourself is a bannable offence.
Mình xin chia sẻ lời giải bài này như sau:
Đặt \(a'=a\text{ % } m\) và \(b'=b\text{ % } m\)
Khi đó ta có: \(x_k = x_{k-1}*a' +b'\)
\(\implies \begin{pmatrix}x_{k-1}&1\end{pmatrix}.\begin{pmatrix}a'&0\\b'&1\end{pmatrix}=\begin{pmatrix}x_{k}&1\end{pmatrix}\)
Đến đây sử dụng luỹ thừa nhị phân, bài toán được giải quyết, các bạn có thể tham khảo code tại đây
Comments