Problem Descriptionlet A is an integral series {A1, A2, ..., an}.
The Zero-order series of A is a itself.
The First-order series of A is {B1, B2, ..., bn-1},where Bi = Ai+1-ai.
The Ith-order series of A are the First-order series of its (i-1) Th-order series (2<=i<=n-1).
Obviously, the (n-1) Th-order series of A is a single integer. Given A, figure out of that integer.
Inputthe input consists of several test cases. The first line of input gives the number of test cases T (t<=10).
For each test case:
The first line contains a single integer n (1<=n<=3000), which denotes the length of series A.
The second line consists of n integers, describing A1, A2, ..., an. (0<=ai<=105)
Outputfor each test case, output the required integer in a line.
Sample Input
231 2 341 5 7 2
Sample Output
0-5
Test instructions: What is the number of final merges?
Idea: Java high-precision, pushed out after the discovery is the coefficient is Yang Hui triangle. Calculation results after processing the coefficients
Import Java.math.biginteger;import java.util.*;import java.io.*;/** * Created by Acer on 14-8-7. */public class Main {public static void Main (string[] args) {Scanner cin = new Scanner (system.in); int t, N; t = Cin.nextint (); while (t! = 0) {t--; n = cin.nextint (); BigInteger arr[] = new Biginteger[n]; for (int i = 0; i < n; i++) {Arr[i] = Cin.nextbiginteger (); } if (n = = 1) {System.out.println (arr[0]); Continue } BigInteger ans = new BigInteger ("0"); BigInteger c[] = new Biginteger[n + 2]; BigInteger T1 = new BigInteger ("0"); BigInteger t2 = new BigInteger ("0"); C[0] = biginteger.valueof (1); for (int i = 1; i < n; i++) {t1 = biginteger.valueof (n-i); T2 = biginteger.valueof (i); C[i] = c[i-1].multiply (T1). Divide (T2); } int flag = 1; for (int i = n-1; I >= 0; i--) {if (flag = =-1) ans = ans.subtract (arr[i].multiply (C[i])); else ans = ans.add (arr[i].multiply (C[i])); Flag *=-1; } System.out.println (ANS); } }}
HDU 4927 Series 1