#P16503. [GKS 2015 #A] gCube
[GKS 2015 #A] gCube
题目描述
Googlers are very interested in cubes, but they are bored with normal three-dimensional cubes and also want to think about other kinds of cubes! A "-dimensional cube" has dimensions, all of equal length. ( may be any positive integer; for example, a -dimensional cube is a line segment, and a -dimensional cube is a square, and a -dimensional cube is a hypercube.) A "-dimensional cuboid" has dimensions, but they might not all have the same lengths.
Suppose we have an -dimensional cuboid. The dimensions are numbered in order (, , , ..., ), and each dimension has a certain length. We want to solve many subproblems of this type:
- Take all consecutive dimensions between the -th dimension and -th dimension, inclusive.
- Use those dimensions to form a -dimensional cuboid, where . (For example, if and , we would form a -dimensional cuboid using the rd, th, th, and th dimensions of our -dimensional cuboid.)
- Reshape it into a -dimensional cube that has exactly the same volume as that -dimensional cuboid, and find the edge length of that cube.
Each test case will have subproblems like this, all of which use the same original -dimensional cuboid.
输入格式
The first line of the input gives the number of test cases, . test cases follow.
Each test case begins with two integers and ; is the number of dimensions and is the number of queries. Then there is one line with positive integers , which are the lengths of the dimensions, in order. Then, lines follow. In the th line, there are two integers and , which give the range of dimensions to use for the th subproblem.
输出格式
For each test case, output one line containing "Case #x:", where x is the test case number (starting from 1). After that, output lines, where the th line has the edge length for the th subproblem. An edge length will be considered correct if it is within an absolute error of of the correct answer.
2
2 2
1 4
0 0
0 1
3 2
1 2 3
0 1
1 2
Case #1:
1.000000000
2.000000000
Case #2:
1.414213562
2.449489743
提示
Limits
.
.
.
Small dataset (Test Set 1 - Visible)
.
.
Large dataset (Test Set 2 - Hidden)
.
.