编程介的小学生 2017-08-08 10:25 采纳率: 20.5%
浏览 704
已采纳

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

  • 写回答

1条回答 默认 最新

  • threenewbee 2017-08-22 15:54
    关注
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 求差集那个函数有问题,有无佬可以解决
  • ¥15 【提问】基于Invest的水源涵养
  • ¥20 微信网友居然可以通过vx号找到我绑的手机号
  • ¥15 寻一个支付宝扫码远程授权登录的软件助手app
  • ¥15 解riccati方程组
  • ¥15 display:none;样式在嵌套结构中的已设置了display样式的元素上不起作用?
  • ¥15 使用rabbitMQ 消息队列作为url源进行多线程爬取时,总有几个url没有处理的问题。
  • ¥15 Ubuntu在安装序列比对软件STAR时出现报错如何解决
  • ¥50 树莓派安卓APK系统签名
  • ¥65 汇编语言除法溢出问题