#P16503. [GKS 2015 #A] gCube

    ID: 16480 Type: RemoteJudge 1000ms 1024MiB Tried: 0 Accepted: 0 Difficulty: 5 Uploaded By: Tags>数学2015Special JudgeGoogle Kick Start

[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 "DD-dimensional cube" has DD dimensions, all of equal length. (DD may be any positive integer; for example, a 11-dimensional cube is a line segment, and a 22-dimensional cube is a square, and a 44-dimensional cube is a hypercube.) A "DD-dimensional cuboid" has DD dimensions, but they might not all have the same lengths.

Suppose we have an NN-dimensional cuboid. The NN dimensions are numbered in order (00, 11, 22, ..., N1N - 1), and each dimension has a certain length. We want to solve many subproblems of this type:

  1. Take all consecutive dimensions between the LiL_i-th dimension and RiR_i-th dimension, inclusive.
  2. Use those dimensions to form a DD-dimensional cuboid, where D=RiLi+1D = R_i - L_i + 1. (For example, if Li=3L_i = 3 and Ri=6R_i = 6, we would form a 44-dimensional cuboid using the 33rd, 44th, 55th, and 66th dimensions of our NN-dimensional cuboid.)
  3. Reshape it into a DD-dimensional cube that has exactly the same volume as that DD-dimensional cuboid, and find the edge length of that cube.

Each test case will have MM subproblems like this, all of which use the same original NN-dimensional cuboid.

输入格式

The first line of the input gives the number of test cases, TT. TT test cases follow.

Each test case begins with two integers NN and MM; NN is the number of dimensions and MM is the number of queries. Then there is one line with NN positive integers aia_i, which are the lengths of the dimensions, in order. Then, MM lines follow. In the iith line, there are two integers LiL_i and RiR_i, which give the range of dimensions to use for the iith subproblem.

输出格式

For each test case, output one line containing "Case #x:", where x is the test case number (starting from 1). After that, output MM lines, where the iith line has the edge length for the iith subproblem. An edge length will be considered correct if it is within an absolute error of 10610^{-6} 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

1T1001 \le T \le 100.

1ai1091 \le a_i \le 10^9.

0LiRi<N0 \le L_i \le R_i < N.

Small dataset (Test Set 1 - Visible)

1N101 \le N \le 10.

1M101 \le M \le 10.

Large dataset (Test Set 2 - Hidden)

1N10001 \le N \le 1000.

1M1001 \le M \le 100.