#CCBCHMOT0000014. Tuổi trung bình (Ages)
Tuổi trung bình (Ages)
Ages
Source: beecrowd
Version: Phuoc Hung OJ Extended
Problem Statement
Read a sequence of integer ages ending at the first negative integer. The negative sentinel is not an age. Compute the arithmetic mean of all preceding nonnegative ages and print exactly two digits after the decimal point. At least one age is guaranteed.
Input
Each line contains one integer age or the negative terminating value.
Output
Print the mean age with exactly two digits after the decimal point.
Subtasks
- Subtask 1 (20%): Exactly one age in [1,100] before sentinel -1.
- Subtask 2 (30%): 1 to 10 ages in [0,100]; the sentinel is in [-1000,-1].
- Subtask 3 (50%): 1 to 1000 ages in [0,120]; the sentinel is in [-1000,-1].
Examples
Example 1
Input
34
56
44
23
-1
Output
39.25
Explanation
The four ages sum to 157; dividing by four gives 39.25. The negative sentinel is excluded.
Example 2
Input
0
20
-1
Output
10.00
Explanation
Age zero is valid, so the mean of 0 and 20 is 10.00.