编程介的小学生 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 安卓adb backup备份应用数据失败
  • ¥15 eclipse运行项目时遇到的问题
  • ¥15 关于#c##的问题:最近需要用CAT工具Trados进行一些开发
  • ¥15 南大pa1 小游戏没有界面,并且报了如下错误,尝试过换显卡驱动,但是好像不行
  • ¥15 没有证书,nginx怎么反向代理到只能接受https的公网网站
  • ¥50 成都蓉城足球俱乐部小程序抢票
  • ¥15 yolov7训练自己的数据集
  • ¥15 esp8266与51单片机连接问题(标签-单片机|关键词-串口)(相关搜索:51单片机|单片机|测试代码)
  • ¥15 电力市场出清matlab yalmip kkt 双层优化问题
  • ¥30 ros小车路径规划实现不了,如何解决?(操作系统-ubuntu)