|
||||||||||
A + B ProblemTime Limit: 6000/3000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 812 Accepted Submission(s): 287 Problem Description Do 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
Sample Output
Author Dumbear@WHU Source | ||||||||||
|