#Lutece0565. KKX Sequence
KKX Sequence
Migrated from Lutece 565 KKX Sequence
All parts of this problem, including description, images, samples, data and checker, might be broken. If you find bugs in this problem, please contact the admins.
Description
KKX likes to play with sequences and find interesting things. For an integer sequence , he subtracts every adjacent two elements to get another sequence of length , , where , . Keep on this method until only one element left. Obviously, for a sequence this number is unique.
KKX wants to know if he can rearrange the elements in the initial sequence in any order, what is maximal number left using the method above?
Please use -bit integers(long long
in C/C++
) to do calculation in this problem. And use the %lld
specificator to read or write -bit integers in C/C++
.
Input
There will be multiple test cases. The first line of the input is an integer () indicating the number of test cases.
For each test case an integer () comes first indicating the number of elements in the initial sequence . The next line contains integers with absolute value within .
Output
Print Case #k: x
in a single line for each test case, in which represents the case number which starts from , and is the maximal number left.
Samples
2
3
1 1 -1
5
2 1 5 -4 2
Case #1: 4
Case #2: 46
Resources
10th UESTC Programming Contest Preliminary