#P4139. 上帝与集合的正确用法
上帝与集合的正确用法
Description
According to some books, one of God’s failed attempts at creation went like this:
On the first day, God created a basic element of the world, called "yuan" (pinyin).
On the second day, God created a new element, called . is defined as a set composed of "yuan". It is easy to see that there are exactly two distinct .
On the third day, God created another new element, called . is defined as a set composed of . It is easy to see that there are four distinct .
On the fourth day, God created a new element, . is defined as a set of . Clearly, there are distinct .
If this continues, the fifth kind of element will have types, and the sixth kind will have types. This will be an astronomical number.
However, God did not anticipate how fast the number of element types would grow. He wanted to enrich the world’s elements, so day after day, year after year, he kept creating new elements…
Not long after, when God created the last kind of element , he found that there were so many elements that the world’s capacity was insufficient to bear them. So that day, God destroyed the world.
To this day, God still remembers that failed act of creation. Now he wants to ask you: how many distinct elements of type are there?
God thinks this number may be too huge to represent, so you only need to report it modulo .
You may assume that from to , God created elements for steps, or steps, or simply steps.
In short:
Define . It can be proved that becomes constant after some index; find that value.
Input Format
The first line contains an integer , the number of test cases.
Each of the next lines contains one positive integer , the modulus.
Output Format
Output lines, each containing one positive integer, which is the answer modulo .
3
2
3
6
0
1
4
Hint
For of the testdata, , .
Translated by ChatGPT 5
京公网安备 11011102002149号