纠结了一天,不知道答案,请大家给点思路^_^
Problem DescriptionDo you know the famous Fibonacci sequence? It is defined by the recurrence
F0 = 0, F1 = 1 and Fn = Fn-1 + Fn-2 for n ≥ 2.
The Fibonacci numbers have many interesting properties. One of them is that the Fibonacci numbers can be used to represent integers. Every positive integer has a unique representation of the form
n = Fk1 + Fk2 + … + Fkm, ki ≥ ki-1 + 2 for 2 ≤ i ≤ m and k1 ≥ 2
For example, 6 can be represented as F2+F5 and 12 can be represented as F2+F4+F6.
Now you know how to represent positive integers with the Fibonacci numbers, can you add them? Given two Fibonacci formed integers, you should calculate the sum of them.
Input
The first line contains a single integer T, indicating the number of test cases.
Each test case contains two lines; each line contains a single integer m followed by m integers k1, k2, …, km indicate a Fibonacci formed integer Fk1+Fk2+…+Fkm.
The input will be always correct.
Technical Specification
1. 1 <= T <= 100
2. 1 <= m <= 100
3. 2 <= ki <= 1000000
Output
For each test case, output the case number first, then a single line indicates the sum of the two Fibonacci formed integer. The sum should be Fibonacci formed like the input.
Sample Input
2
1 2
2 2 4
3 2 4 6
2 2 5
Sample Output
Case 1:
1 5
Case 2:
2 5 7