#P1939. 矩阵加速(数列)
矩阵加速(数列)
Description
Given a sequence , it satisfies:
$$a_x= \begin{cases} 1 & x \in\{1,2,3\}\\ a_{x-1}+a_{x-3} & x \geq 4 \end{cases}$$Find the -th term of sequence modulo .
Input Format
The first line contains an integer , denoting the number of queries. Each of the following lines contains a positive integer .
Output Format
Output one non-negative integer per line, representing the answer.
3
6
8
10
4
9
19
Hint
- For of the testdata, .
- For of the testdata, .
- For of the testdata, , .
Translated by ChatGPT 5
京公网安备 11011102002149号