#K39952. Array Statistics and Cumulative Operations

    ID: 26534 Type: Default 1000ms 256MiB

Array Statistics and Cumulative Operations

Array Statistics and Cumulative Operations

In this problem, you are given an array of integers of size (N). Your task is to compute several statistical operations on the array. Specifically, you need to compute the cumulative sum, cumulative product, mean, variance, and standard deviation of the array elements.

The cumulative sum and cumulative product are defined as follows:

  • Cumulative sum: (S_i = a_1 + a_2 + \cdots + a_i) for (i=1,2,\dots,N).
  • Cumulative product: (P_i = a_1 \times a_2 \times \cdots \times a_i) for (i=1,2,\dots,N).

The mean (\mu) is computed using the formula: [ \mu = \frac{1}{N} \sum_{i=1}^{N} a_i ]

The variance (\sigma^2) is defined as: [ \sigma^2 = \frac{1}{N} \sum_{i=1}^{N} (a_i - \mu)^2 ]

and the standard deviation is the square root of the variance: [ \sigma = \sqrt{\sigma^2} ]

Your program should read input from standard input (stdin) and write the result to standard output (stdout) exactly in the specified format.

inputFormat

The input consists of two lines:

  1. The first line contains a single integer (N), the size of the array.
  2. The second line contains (N) space-separated integers representing the elements of the array.

outputFormat

The output should consist of five lines:

  1. The first line contains the cumulative sums, separated by a space.
  2. The second line contains the cumulative products, separated by a space.
  3. The third line contains the mean of the array (a floating point number).
  4. The fourth line contains the variance of the array (a floating point number).
  5. The fifth line contains the standard deviation of the array (a floating point number).## sample
5
1 2 3 4 5
1 3 6 10 15

1 2 6 24 120 3.0 2.0 1.4142135623730951

</p>