Series 1
Note:
It is not easy to translate the question. It is not difficult to understand English.
Problem descriptionlet A be an integral series {A1, A2,..., }.
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 is the first-order series of its (I-1) Th-order series (2 <= I <= n-1 ).
Obviusly, The (n-1) Th-order series of A is a single integer. Given a, figure out 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.
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 input2 3 1 2 3 4 1 5 7 2
Sample output0-5 train of thought: Nan Jie quickly introduced the formula in the competition. He wanted to pre-process Yang Hui triangle and then found that the size of biginteger burst into memory .... I am speechless and want to optimize it on the basis of violence, and then I will never die... The competition is not over yet. After the game, I learned that the Yang Hui triangle can be launched directly using the combination formula... The number of M in row N in the Yang Hui triangle is the number of composite C [n-1] [M-1]. The application C [N] [m] = C [N] [M-1] * (N-m + 1)/m enables express delivery to launch the nth line number, this not only avoids the memory burst during table hitting, but also saves a lot of time for brute force ..... Still too young...
import java.io.*;import java.math.*;import java.util.*;public class Main { static BigInteger coe[][] = new BigInteger [3010][3010];public static void main(String[] args) throws IOException{Scanner cin = new Scanner(System.in);BigInteger []a = new BigInteger[3010]; BigInteger []c = new BigInteger[3010]; int T;T = cin.nextInt();while(T-- > 0){int n;n = cin.nextInt();for(int i = 1; i <= n; ++i){a[i] = cin.nextBigInteger();}BigInteger ans = BigInteger.ZERO;c[0] = BigInteger.ONE;ans = ans.add(c[0].multiply(a[n]));int t = -1;for(int i = 1; i < n; ++i){BigInteger t1 = BigInteger.valueOf(n).subtract(BigInteger.valueOf(i)); BigInteger t2 = BigInteger.valueOf(i); c[i] = c[i-1].multiply(t1).divide(t2); ans = ans.add(c[i].multiply(a[n-i]).multiply(BigInteger.valueOf(t))); t *= -1; }System.out.println(ans);}}}