luogu#P4838. P哥破解密码
P哥破解密码
Background
Brother P is a boy who often loses his password slips.
At the ION8102 contest site, Brother P lost his password slip again. As someone who can get full marks on the written test, he of course knows that this will cost him points as a penalty, so he started cracking the password of the IONXunil system.
Problem Description
Define a string as valid if and only if it is made up only of and , and it does not contain consecutive characters. Brother P knows that the password is the number of valid strings of length , taken modulo . But Brother P cannot compute it, so he can only tell you and ask you to compute it.
As for why the result is taken modulo this number, it seems to be in memory of someone, but who exactly that is, Brother P does not remember either.
However, he forgot what the string length should be, so he plans to try sets of testdata.
Input Format
The first line gives an integer , which represents the number of queries.
Then follow lines, each giving a positive integer , meaning the length of the string in that query.
Output Format
For each query, output one integer per line, representing the answer.
3
1
3
6
2
7
44
Hint
Explanation of the samples.
When the length is , there are only two arrangements: and , and both are valid.
When the length is , all strings are valid except , so there are strings.
Constraints.
- For of the testdata, all , .
- For of the testdata, all .
- For of the testdata, all , .
Translated by ChatGPT 5