编程介的小学生 2017-08-22 16:18 采纳率: 20.5%
浏览 738
已采纳

Tower

Once upon a time, there was a temple. And the honor of the monks in the temple is their tower.One day, the Buddhist abbot wants to find out who is the smartest monk in the temple, so he gives the monks a problem: Calculate the area of the tower's shadow at a specific time of the day. Perhaps the mission is easy to complete with a directly measuring the shadow, but the Buddhist abbot makes it nearly impossible, he said:

"Leave the shadow alone! You can only measure the tower itself!"

Though all the monks are very smart, they still have no idea of this problem. So now it is your turn to solve it.

The tower is formed with N floors, each floor is a hexagon, and every two adjacent floors will be linked by six congruent isosceles trapezoid (For example, floor N links to floor N-1, floor 2 links to floor 1, floor 1 links to floor 0). The top of the tower, which can be regarded as floor 0, is a dot (that is, it can be treated as a hexagon with a zero side length). Then floor 1 is the floor under floor 0, floor 2 is under floor 1, floor 3 is under floor 2...floor N is under floor (N - 1). Now let Ri equals to the side length of hexagon number i, Hi equals to the height of floor i (of course it's the height from the bottom), and you know the shadow's length L of a exactly vertically placed stick (Its height exactly equals to 1. We assume that sun light is parallel light, and it is perpendicular to two parallel sides of each hexagon).
Now give you Ri, Hi and L, can you solve the problem?

Input

There are several test cases.
In each case, there will be two numbers in the first line, N(integer, 1 <= N <= 150) and L(fraction, L >= 0), which represent the number of floot and the shadow's length of the stick. The next N + 1 lines describe the side length Ri and height Hi(i starts from 0 to N), each line contains only two numbers, Ri and Hi(fractions, 0.00 <= Ri, Hi < 1000.00).We guarantee that Hi > Hj(0 <= i < j <= N), R0 = 0 and Hn = 0.

Output

For each test case, you may output a float number S, which represents the area of the tower's shadow. Round S to 4 digits after decimal point.

Sample Input

1 1.00
0.00 3.00
1.00 0.00
3 0.00
0.00 3.00
10.00 2.00
5.00 1.00
11.00 0.00
Sample Output

4.2990
314.3672

  • 写回答

2条回答 默认 最新

  • threenewbee 2017-08-27 15:15
    关注
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 matlab有关常微分方程的问题求解决
  • ¥15 perl MISA分析p3_in脚本出错
  • ¥15 k8s部署jupyterlab,jupyterlab保存不了文件
  • ¥15 ubuntu虚拟机打包apk错误
  • ¥199 rust编程架构设计的方案 有偿
  • ¥15 回答4f系统的像差计算
  • ¥15 java如何提取出pdf里的文字?
  • ¥100 求三轴之间相互配合画圆以及直线的算法
  • ¥100 c语言,请帮蒟蒻写一个题的范例作参考
  • ¥15 名为“Product”的列已属于此 DataTable