310524: CF1846D. Rudolph and Christmas Tree

Memory Limit:256 MB Time Limit:2 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

D. Rudolph and Christmas Treetime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard output

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 $d$ and height $h$, 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 $i$-th triangle is located at a height of $y_i$.

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

Help Rudolph calculate the total area of the tree branches.

Input

The first line contains a single integer $t$ ($1 \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, h$ ($1 \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 $n$ integers $y_i$ $(1 \le y_i \le 10^9, y_1 < y_2 < ... < y_n)$ — the heights of the bases of the branches.

The sum of $n$ over all test cases does not exceed $2 \cdot 10^5$.

Output

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 $10^{-6}$.

ExampleInput
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

Input

题意翻译

一颗圣诞树由 $n$ 个底边为 $d$,高度为 $h$ 的等腰三角形组成,每个三角形以 $y$ 轴为对称轴,底边均平行于 $x$ 轴,三角形有可能重叠。 给出 $n,d,h$ 以及每个三角形底边与 $x$ 轴的距离,求该圣诞树的面积。 有 $T$ 组数据。 by @[Larryyu](https://www.luogu.com.cn/user/475329)

Output

**题目大意:**

鲁道夫画了一棵漂亮的圣诞树,并决定打印出这幅画。然而,墨盒中的墨水总是在最不方便的时刻用完。因此,鲁道夫想提前计算他需要多少绿色墨水。

这棵树有一个垂直的树干和在不同高度上相同的三角形树枝。树干的厚度可以忽略不计。

每个树枝都是一个底边为 $ d $ 和高为 $ h $ 的等腰三角形,其底边垂直于树干。这些三角形向上以一定角度排列,树干正好位于中间。第 $ i $ 个三角形的底边位于高度 $ y_i $。

下面的图展示了一个例子,其中 $ d = 4, h = 2 $,树枝的底边高度为 $[1, 4, 5]$。

帮助鲁道夫计算树的所有树枝的总面积。

**输入数据格式:**

第一行包含一个整数 $ t $ ($ 1 \le t \le 10^4 $) —— 测试用例的数量。

接下来是每个测试用例的描述。

每个测试用例的第一行包含三个整数 $ n, d, h $ ($ 1 \le n, d, h \le 2 \cdot 10^5 $) —— 分别是树枝的数量、树枝的底边长度和树枝的高度。

每个测试用例的第二行包含 $ n $ 个整数 $ y_i $ ($ 1 \le y_i \le 10^9, y_1 < y_2 < ... < y_n $) —— 树枝底边的高度。

所有测试用例中 $ n $ 的总和不超过 $ 2 \cdot 10^5 $。

**输出数据格式:**

对于每个测试用例,输出一个实数,即树的所有树枝的总面积。如果答案的绝对误差或相对误差不超过 $ 10^{-6} $,则答案被认为是正确的。**题目大意:** 鲁道夫画了一棵漂亮的圣诞树,并决定打印出这幅画。然而,墨盒中的墨水总是在最不方便的时刻用完。因此,鲁道夫想提前计算他需要多少绿色墨水。 这棵树有一个垂直的树干和在不同高度上相同的三角形树枝。树干的厚度可以忽略不计。 每个树枝都是一个底边为 $ d $ 和高为 $ h $ 的等腰三角形,其底边垂直于树干。这些三角形向上以一定角度排列,树干正好位于中间。第 $ i $ 个三角形的底边位于高度 $ y_i $。 下面的图展示了一个例子,其中 $ d = 4, h = 2 $,树枝的底边高度为 $[1, 4, 5]$。 帮助鲁道夫计算树的所有树枝的总面积。 **输入数据格式:** 第一行包含一个整数 $ t $ ($ 1 \le t \le 10^4 $) —— 测试用例的数量。 接下来是每个测试用例的描述。 每个测试用例的第一行包含三个整数 $ n, d, h $ ($ 1 \le n, d, h \le 2 \cdot 10^5 $) —— 分别是树枝的数量、树枝的底边长度和树枝的高度。 每个测试用例的第二行包含 $ n $ 个整数 $ y_i $ ($ 1 \le y_i \le 10^9, y_1 < y_2 < ... < y_n $) —— 树枝底边的高度。 所有测试用例中 $ n $ 的总和不超过 $ 2 \cdot 10^5 $。 **输出数据格式:** 对于每个测试用例,输出一个实数,即树的所有树枝的总面积。如果答案的绝对误差或相对误差不超过 $ 10^{-6} $,则答案被认为是正确的。

加入题单

上一题 下一题 算法标签: