Time limit 2000/4000/4000/4000 ms. Memory limit 65000/65000/65000/65000 Kb. Question by Ibrahim Mesecan.
Harmonic Mean
Harmonic mean is one of the ways to calculate the average
of a series. It is the reciprocal
of the arithmetic mean of reciprocals.
Question: Write a program that
calculates the harmonic mean of n numbers.
Input specification
You will be first given a number n, the number of
numbers where 0 ≤ n ≤ 1,000.
Then, in the following line, you will be
given n numbers where the numbers are floating point
numbers greater than 0 and less than 50,000.
Output specification:
Show one floating point number with 2 digits precision.
Sample Input I
3
5 6 1
|
Sample Input II
5
8 8 1 9 7
|
Sample Output I
2.20
|
Sample Output II
3.32
|
Explanation: There are 3 numbers given.
And, sum of reciprocals (1/5) + (1/6) + (1/1) = 1.3667
Then, the Harmonic mean is 3/1.3667 = 2.1951
Для отправки решений необходимо выполнить вход.
|