F.A.Q
Hand In Hand
Online Acmers
Problem Archive
Realtime Judge Status
Authors Ranklist
 
     C/C++/Java Exams     
ACM Steps
Go to Job
Contest LiveCast
ICPC@China
Best Coder beta
VIP | STD Contests
    DIY | Web-DIY beta
Author ID 
Password 
 Register new ID

A + B Problem

Time 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
2 1 2 2 2 4 3 2 4 6 2 2 5
 

Sample Output
Case 1: 1 5 Case 2: 2 5 7
 

Author
Dumbear@WHU
 

Source
 

Statistic | Submit | Discuss | Note
Hangzhou Dianzi University Online Judge 3.0
Copyright © 2005-2024 HDU ACM Team. All Rights Reserved.
Designer & Developer : Wang Rongtao LinLe GaoJie GanLu
Total 0.000000(s) query 1, Server time : 2024-04-27 18:17:37, Gzip enabled