Answer many range queries asking for the geometric mean of array values with nine digits after the decimal point.
Medium5Prefix sumMathNo attempts yetTime limit5sMemory limit512 MBA D-dimensional cube has D dimensions whose lengths are all equal. D may be 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 one N-dimensional cuboid. Its dimensions are numbered 0,1,…,N−1 in order, and dimension i has length ai. Solve M subproblems of the following form.
All M subproblems of one test case use the same N-dimensional cuboid.
The first line has the number of test cases T. Then T test cases follow.
The first line of each test case has the number of dimensions N and the number of queries M. The next line has the lengths of the dimensions a0,a1,…,aN−1 in order. Of the M lines that follow, line i has the range Li and Ri of dimensions that the i-th subproblem uses.
For each test case, first print one line of the form Case #x:, where x is the test case number starting at 1. Then print M lines; line i has the edge length of the i-th subproblem, written with exactly nine digits after the decimal point. Round at the tenth digit after the decimal point.
The edge length is the D-th root of aLi×⋯×aRi. That value is usually irrational and reaches 109 in size, so double precision floating point alone does not give nine correct digits.