HomeVolumesContestsSectionsForumsUsersPrintHelpAbout

Volumes > Repetition (Loops) > problem:


50871 - Harmonic Mean

Guest
• Review clarifications (2)

Volume problems

• 50815 - Breaking the Bunker
• 50899 - How Many Years
• 50806 - TVSH
• 51078 - Max trade
• 50820 - Post Office
• 50807 - Euro to Leke
• 50810 - Print Office
• 50952 - Derby Tirana
• 50871 - Harmonic Mean
• 50859 - Low performance
• 50508 - The Biggest Area
• 51077 - Grades Histogram
• 50528 - Rock-Scissors-Paper
• 50744 - The Smallest Perimeter
• 50808 - Total Distance Traveled
• 50814 - Buying Books from Internet
• 50812 - Total Discount for the clients

Feedback

If you notice incorrect translations in Contester, please let author know.

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



Для отправки решений необходимо выполнить вход.

www.contester.ru