gCube (Small)
Time limit5sMemory limit512 MB
Compute the geometric mean of each queried subarray and print it with nine digits after the decimal point.
- Level
Medium4 of 10
- Topics
- Math
- Solved
- No attempts yet
Problem
A -dimensional cube has dimensions of equal length. 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 -dimensional cuboid also has dimensions, but their lengths may differ.
You are given an -dimensional cuboid. Its dimensions are numbered in order, and dimension has length . Answer queries of the following form.
- Take the consecutive dimensions from the -th one to the -th one, inclusive.
- Build a -dimensional cuboid from those dimensions, where . For example, if and , the new cuboid uses dimensions 3, 4, 5, and 6.
- Reshape that cuboid into a -dimensional cube with exactly the same volume, and report the edge length of the cube.
Every query of a test case uses the same original -dimensional cuboid.
Input
The first line has the number of test cases . The test cases follow.
Each test case begins with a line holding two integers and , the number of dimensions and the number of queries. The next line has positive integers , the lengths of the dimensions in order. Each of the next lines has two integers and , the range of dimensions used by the -th query.
Output
For each test case, print one line "Case #x:", where x is the number of the test case starting from 1. Then print lines, where the -th line has the edge length for the -th query.
The edge length for a query is with . 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 , 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.