问题 H: Jiulianhuan

问题 H: Jiulianhuan

时间限制: 1 Sec  内存限制: 128 MB
提交: 100  解决: 24
[状态] [讨论版] [提交] [命题人:]
  For each data set in the input print on a separate line, on the standa  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!d output, the integer that represents the maximal amount of overtaking.

Now, I would like to mention the rules or common sense of Jiulianhuan again.
1) 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.
2) At any moment, you can only operate one ring, on the condition that the ring is operable.
3) If the first k-2 rings are under the handle, and the (k-1)th ring is on the handle, then if the k-th 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.

  Given n (not bigger than 10^8), you are to output the minimum steps it needs to down n well-put rings. There are no more than 100 test cases.

  A number a line. Because the number are so huge ,you are to output the result after it mod prime 10007.

样例输入 Copy
样例输出 Copy