Problem
Given a 2x2xN box, in how many ways can you fill it with 1x1x2 blocks?
Input Format
The input starts with an integer T - the number of test cases (T <= 10,000). T cases follow on each subsequent line, each of them containing the integer N (1 <= N <= 1,000,000).
Output Format
For each test case, print the number of ways to fill the box modulo 1,000,000,007
Sample Input
|
|
Sample Output
|
|
Solution
把幾種情況畫出來,會發現有一種特別的之之型,最後會接上一個 1x2 的來湊滿一個 2 x 2 x N 的情況,為此我們必須要知道有多少這種之之型可以從哪裡拆分出來。
會在代碼中發現一個變數 c 存放的便是以之之型結束的方法數,之之型可以把最後一個 1x2 拿走,繼續延伸。
|
|