KKX Sequence (CDOJ1644)
来源:互联网 发布:网吧无限上网软件 编辑:程序博客网 时间:2024/05/16 23:58
KKX Sequence
Time Limit: 1000 ms Memory Limit: 65536 kB Solved:142 Tried: 754
Description
KKX likes to play with sequences and find interesting things. For an integer sequence A[1], A[2], …, A[N], he subtracts every adjacent two elements to get another sequence of length N-1, B[1], B[2], …, B[N-1], where B[i] = A[i] – A[i+1], i = 1, 2, …, N-1. 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 A in any order, what is maximal number left using the method above?
Please use 64-bit integers(long long in C/C++) to do calculation in this problem. And use the"%lld" specificator to read or write 64-bit integers in C/C++.
Input
There will be multiple test cases. The first line of the input is an integer T (T <= 100) indicating the number of test cases.
For each test case an integer N (1 <= N <= 50) comes first indicating the number of elements in the initial sequence A. The next line contains N integers with absolute value within 1000.
Output
Print “Case #k: x” in a single line for each test case, in which k represents the case number which starts from 1, and x is the maximal number left.
Simple Input
2
3
1 1 -1
5
2 1 5 -4 2
Simple Output
Case #1: 4
Case #2: 46
Source
10th UESTC Programming Contest Preliminary
解法,利用杨辉三角。把第N行的数第一个为正,第二个为负,第三个为正的一行的数取出排序与输入的数进行排序后进行点乘即可。
- KKX Sequence (CDOJ1644)
- CDOJ 1644 KKX Sequence
- CDOJ 1644 KKX Sequence
- Easy Problem(cdOJ1644)
- 紐巴倫 Fxhx kKx yiYln
- sequence
- SEQUENCE
- Sequence
- sequence
- sequence
- Sequence
- sequence
- sequence
- sequence
- Sequence
- Sequence
- Sequence
- Sequence
- 再转:orakill
- EntityManagerHelper无效
- C++知识框架解析(2)
- DNS的功能
- linux物理内存描述
- KKX Sequence (CDOJ1644)
- 移植TX2440A的ADS项目到MDK4.12+jlink
- 在Android工程中管理Activity的生命周期
- C2039 Error: WriteHuge : is not a member of CFile
- sql 行转列
- 详解UIView的frame、bounds和center属性
- java中的transient
- 是否retina高清屏,判断当前设备
- Oracle 如何找回已经删除了的表