Http://acm.hdu.edu.cn/showproblem.php? PID = 1, 1121
Here is a series of integers that contain S integers, so that you can find the polynomial P (n) = AD. N ^ d + aD-1.n ^ D-1 +... + a1.n + a0: When the degree of the polynomial is the hour, the following C integers are output to satisfy the polynomial.
AlgorithmAnalysis: HDU recommended for DP, no idea, find the problem report (http://rchardx.is-programmer.com/posts/16142.html), said to be differential. My understanding is as follows: Find the difference between each item and the previous one, and then observe the law, for any polynomial satisfying P (n) = AD. N ^ d + aD-1.n ^ D-1 +... + a1.n + a0 of the d degree polynomial, take the first order of the difference: TMP = P (n)-(N-1) must be a D-1 degree polynomial, and so on, take the n-1 order difference, and there is only one number D (ProgramFor f [n-1] [0]), if D = 0, if you want to minimize the order of P (n), the next M number in the n-1 difference should be 0, if D! = 0, when the next M number is d, then the first order of the n-2 is a polynomial of the First Order (only the first degree of Polynomial (a1.n + a0, tolerances for A1) the difference is a constant), The n-1 order is 0 order polynomial, in order to ensure the minimum order d
Code
# Include < Stdio. h >
# Define Nn 102
Int Main ()
{
Int T, I, J, S, C;
Int F [NN] [NN];
Scanf ( " % D " , & T );
While (T -- ){
Scanf ( " % D " , & S, & C );
For (I = 0 ; I < S; I ++ )
Scanf ( " % D " , & F [ 0 ] [I]);
For (I = 1 ; I < S; I ++ )
For (J = 0 ; I + J < S; j ++ )
F [I] [J] = F [I - 1 ] [J + 1 ] - F [I - 1 ] [J];
For (I = 1 ; I <= C; I ++ )
F [s - 1 ] [I] = F [s - 1 ] [ 0 ];
For (I = S - 2 ; I > = 0 ; I -- )
For (J = S - I; j < C + S; j ++ )
F [I] [J] = F [I] [J - 1 ] + F [I + 1 ] [J - 1 ];
For (I = S; I < S + C - 1 ; I ++ )
Printf ( " % D " , F [ 0 ] [I]);
Printf ( " % D \ n " , F [ 0 ] [I]);
}
Return 0 ;
}