The expected value is the weighted average of all possible outcomes of an experiment, weighted with the probabilities of each particular outcome. For a random variable , the expected value is written as .
Intuitively, the expected value is the long run average value of repetitions of the experiment.
The variance is the expected value of the outcome's squared deviation from its expected value. For a random variable , the variance is written as and is defined as the expected value of .
Intuitively, the variance is a measure of how far the outcomes of an experiment are spread out. The higher the variance, the more spread out the outcomes.
Let's say we perform the following experiment involving throwing a die:
Throw the die, and record the outcome as d[1].
For i from 2 to N:
Repeatedly throw the die until the outcome is different from d[i-1].
Record the outcome as d[i].
Output d[1] + d[2] + ... + d[N].
The die used in this experiment is a standard 6-sided die with outcomes . However, it is biased. In each throw, the probability of appearing is for .
Find the expected value and variance of the outcome of this experiment.
Note: Certain formulas for variance are not fit for computation because of loss of significance/numerical instability. This link contains a discussion about how to avoid/mitigate this problem.
Input Format
The first six lines contain the probabilities of the die's outcomes. Specifically, the th line contains , for .
The seventh (and final) line contains , the number of times the die is thrown.
Constraints
For test cases worth of the total points:
For test cases worth of the total points:
For test cases worth of the total points:
Output Format
The first line of output contains the expected value.
The second line contains the variance.
The answer will be accepted if it is within an absolute error of of the true answer.
Sample Input
0.16666666667
0.16666666666
0.16666666667
0.16666666667
0.16666666666
0.16666666667
2
Sample Output
7.0
4.66666666666
Explanation
One can verify these results by writing code that performs the experiment, running it multiple times, and computing the expected value and variance from the outcomes. The more times the experiment is run, the more accurate the answer will be.