CF BUDDY
← Problems·

1846D · Rudolph and Christmas Tree

1200 · constructive algorithms, geometry, math

Problem: Rudolph drew a beautiful Christmas tree and decided to print the picture. However, the ink in the cartridge often runs out at the most inconvenient moment. Therefore, Rudolph wants to calculate in advance how much green ink he will need.

The tree is a vertical trunk with identical triangular branches at different heights. The thickness of the trunk is negligible.

Each branch is an isosceles triangle with base dd and height hh, whose base is perpendicular to the trunk. The triangles are arranged upward at an angle, and the trunk passes exactly in the middle. The base of the ii-th triangle is located at a height of yiy_i.

The figure below shows an example of a tree with d=4,h=2d = 4, h = 2 and three branches with bases at heights [1,4,5][1, 4, 5].

Help Rudolph calculate the total area of the tree branches.

Input Format: The first line contains a single integer tt (1t1041 \le t \le 10^4) — the number of test cases.

Then follow the descriptions of the test cases.

The first line of each test case contains three integers n,d,hn, d, h (1n,d,h21051 \le n, d, h \le 2 \cdot 10^5) — the number of branches, the length of the base, and the height of the branches, respectively.

The second line of each test case contains nn integers yiy_i (1yi109,y1<y2<...<yn)(1 \le y_i \le 10^9, y_1 < y_2 < ... < y_n) — the heights of the bases of the branches.

The sum of nn over all test cases does not exceed 21052 \cdot 10^5.

Output Format: For each test case, output a single real number on a separate line — the total area of the tree branches. The answer will be considered correct if its absolute or relative error does not exceed 10610^{-6}.

Sample Cases

Case 1

Input

5
3 4 2
1 4 5
1 5 1
3
4 6 6
1 2 3 4
2 1 200000
1 200000
2 4 3
9 11

Output

11
2.5
34.5
199999.9999975
11.333333

Similar problems

00:00:00
Loading editor…
Welcome! I'm your coding tutor for this problem. Use the chips below to reveal stored hints or get AI feedback on your code. I'll guide you step by step — never giving away the solution.

Sign in to unlock AI tutor feedback