CF1846D.Rudolph and Christmas Tree
普及-
通过率:0%
时间限制:2.00s
内存限制:256MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
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 yi.
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.
鲁道夫画了一棵漂亮的圣诞树,并打算将这幅画打印出来。然而,墨盒中的墨水总是在最不方便的时候用完。因此,鲁道夫希望提前计算出他需要多少绿色墨水。
这棵树由一根竖直的树干和在不同高度处排列的若干全等三角形枝杈组成。树干的粗细可忽略不计。
每个枝杈是一个底边长为 d、高为 h 的等腰三角形,其底边垂直于树干。这些三角形以一定角度向上排列,且树干恰好穿过每个三角形的正中心(即底边中点的垂线与树干重合)。第 i 个三角形的底边位于高度 yi 处。
下图展示了一棵具有 d=4, h=2 且三个枝杈底边分别位于高度 [1,4,5] 处的树的示例:

请帮助鲁道夫计算整棵树所有枝杈的总面积。
输入格式
The first line contains a single integer t (1≤t≤104) — 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≤n,d,h≤2⋅105) — 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 yi (1≤yi≤109,y1<y2<...<yn) — the heights of the bases of the branches.
The sum of n over all test cases does not exceed 2⋅105.
第一行包含一个整数 t(1≤t≤104)—— 测试用例的数量。
接下来是各测试用例的描述。
每个测试用例的第一行包含三个整数 n,d,h(1≤n,d,h≤2⋅105)—— 分别表示分支的数量、底边长度和分支的高度。
每个测试用例的第二行包含 n 个整数 yi(1≤yi≤109,且 y1<y2<⋯<yn)—— 表示各分支底端的高度。
所有测试用例中 n 的总和不超过 2⋅105。
输出格式
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.
对于每个测试用例,在单独一行输出一个实数——树的枝干总面积。若答案的绝对误差或相对误差不超过 10−6,则视为正确。
输入输出样例
输入#1
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
输出#1
11 2.5 34.5 199999.9999975 11.333333
输入解题思路,AI测评打分。不知道怎么写?