#C5618. Polynomial Indefinite Integration

    ID: 49287 Type: Default 1000ms 256MiB

Polynomial Indefinite Integration

Polynomial Indefinite Integration

You are given a polynomial \(P(x)\) represented by a list of coefficients in ascending order of power. In other words, the polynomial is given as \(P(x)=a_0+a_1x+a_2x^2+\cdots+a_{n-1}x^{n-1}\). Your task is to compute its indefinite integral \(Q(x)=\int P(x)\,dx\) using the formula:

[ Q(x)=\left[0,;\frac{a_0}{1},;\frac{a_1}{2},;\frac{a_2}{3},;\dots,;\frac{a_{n-1}}{n},;C\right] ]

where \(C\) is the constant of integration. Notice that the output is a list of coefficients of \(Q(x)\) with an extra initial 0 and the constant \(C\) appended in the last position.

If the input polynomial has no coefficients (i.e. an empty polynomial), simply output the list [0, C].

inputFormat

The input is read from standard input (stdin) and consists of three parts:

  • The first line contains an integer \(n\) \((\ge 0)\) representing the number of coefficients of the polynomial \(P(x)\).
  • If \(n > 0\), the second line contains \(n\) space-separated numbers (integers or decimals) representing the coefficients \(a_0, a_1, \dots, a_{n-1}\) in ascending order of power. If \(n = 0\), the second line will be empty.
  • The third line contains a single number representing the constant of integration \(C\).

outputFormat

Print to standard output (stdout) the coefficients of the integrated polynomial \(Q(x)\) as a list in one line, separated by a single space. The format of the list is:

[0,;\frac{a_0}{1},;\frac{a_1}{2},;\cdots,;\frac{a_{n-1}}{n},;C]

Note: For the coefficients that result from division, print them in decimal format (e.g. 1 should be printed as 1.0) and for the constant of integration, if it is an integer, print it without a decimal point.

## sample
2
1 2
0
0 1.0 1.0 0