#Lutece0932. Jiulianhuan
Jiulianhuan
Migrated from Lutece 932 Jiulianhuan
All parts of this problem, including description, images, samples, data and checker, might be broken. If you find bugs in this problem, please contact the admins.
Description
I think that you might have played the traditional Chinese ring game: The Chinese Linking Rings (here we call its nickname Jiulianhuan —— 九连环
). Well, you say you haven’t played it before? Then you must have seen it before, right? If not seen, come to borrow mine to have a good look at it and enjoy it!
Now, I would like to mention the rules or common sense of Jiulianhuan again.
- The first ring can put on or down the handles at any time. That is, when the first ring is under the handle, it can climb up the handle within one step, and vice versa.
- At any moment, you can only operate one ring, on the condition that the ring is operable.
- If the first rings are under the handle, and the ring is on the handle, then if the ring is under the handle, you can put it on the handle, and if it is not under the handle, you can put it down the handle.
Seems complicated? But I tried my simplest explanation to you, and I hope its not hard for you to understand. Maybe you have played the game before, and the above is what actually a
step
means in the game.
Input
Given (not bigger than ), you are to output the minimum steps it needs to down well-put rings. There are no more than test cases.
Output
A number a line. Because the number are so huge, you are to output the result after it mod prime .
Samples
1
2
9
1005
1
2
341
4260
Resources
2011 Heilongjiang collegiate programming contest