Compute the geometric mean of each queried subarray and print it with nine digits after the decimal point.
Medium4MathNo attempts yetTime limit5sMemory limit512 MBA D-dimensional cube has D dimensions of equal length. D is any positive integer, so a 1-dimensional cube is a line segment, a 2-dimensional cube is a square, and a 4-dimensional cube is a hypercube. A D-dimensional cuboid also has D dimensions, but their lengths may differ.
You are given an N-dimensional cuboid. Its dimensions are numbered 0,1,2,…,N−1 in order, and dimension i has length ai. Answer M queries of the following form.
Every query of a test case uses the same original N-dimensional cuboid.
The first line has the number of test cases T. The T test cases follow.
Each test case begins with a line holding two integers N and M, the number of dimensions and the number of queries. The next line has N positive integers a0,a1,…,aN−1, the lengths of the dimensions in order. Each of the next M lines has two integers Li and Ri, the range of dimensions used by the i-th query.
For each test case, print one line "Case #x:", where x is the number of the test case starting from 1. Then print M lines, where the i-th line has the edge length for the i-th query.
The edge length for a query is (∏j=LiRiaj)1/D with D=Ri−Li+1. Print it with exactly 9 digits after the decimal point, rounding the exact value half up at the ninth decimal place. The root is usually irrational and the product reaches 1090, so compute it precisely enough that the ninth decimal digit is correct. Always print at least one digit before the decimal point and never print a plus sign.