MEANSTRIC - Tricky Means

Given n strictly positive real numbers, your task is to compute the Pythagorean means:

  • The arithmetic mean « A »

the arithmetic mean is the sum of a collection of numbers divided by the count of numbers in the collection.

  • The geometric mean « G » (mean of rates of growth)

G = The geometric mean is defined as the nth root of the product of n numbers

  • The harmonic mean « H » (mean of speeds)

The harmonic mean can be expressed as the reciprocal of the arithmetic mean of the reciprocals of the given set of observations

A geometric construction of the quadratic mean and the Pythagorean means (of two numbers a and b). Harmonic mean denoted by H, geometric by G, arithmetic by A and quadratic mean (also known as root mean square) denoted by Q.

Figure 1: Geometric interpretation of the Pythagorean means of two numbers a and b

Input

The first line of the input contains an integer T denoting the number of test cases. The description of T test cases follows. Each test case is described in two lines: the first line contains a single integer « n » (1 ≤ n ≤ 100) indicating the number of the strictly positive real numbers and the second line contains « n » space-separated strictly positive real numbers.

Output

For each test case, print a single line containing three space-separated integers: « A », « G », « H » which are respectively the arithmetic, the geometric and the harmonic means of the given strictly positive real numbers. Each mean must be given with a precision of 10-9.

Example

Input:
3
5
4 36 45 50 75
6
1.0 2.0 4.0 7.0 14.0 28.0
8
1.0 2.0 3.0 4.0 9.0 12.0 18.0 36.0

Output:
42.000000000 30.000000000 15.000000000
9.333333333 5.291502622 3.000000000
10.625000000 6.000000000 3.388235294

Added by:mbk_live
Date:2019-01-08
Time limit:1s
Source limit:50000B
Memory limit:1536MB
Cluster: Cube (Intel G860)
Languages:C-CLANG C NCSHARP C++ 4.3.2 CPP CPP14 CPP14-CLANG C99 JAVA JULIA PYTHON PYPY3 PYTHON3 SWIFT

hide comments
2024-10-24 22:41:00
easy, but requires a pen and a sheet =)

ac with c++ double
© Spoj.com. All Rights Reserved. Spoj uses Sphere Engine™ © by Sphere Research Labs.