编程介的小学生 2017-09-29 16:19 采纳率: 20.5%
浏览 865
已采纳

Battery

Problem Description
Recently hzz invented a new kind of solar battery. The battery is so amazing that the electric power generated by it can satisfy the entire village. People in the villager are all very happy since they can get free and green energy from now on. But the manager of a power company is sorrow about this. So he plans to take some action to obstruct the battery.

The battery can be regarded as a segment of L meters. And the manager plans to build n pillars on the battery.

Like the picture above, the distance between pillar i and the battery's left end is Xi, and its height is Hi. The thickness of all pillars can be ignored. When the sunlight is slant, some part of the battery will be sheltered by the pillars.

One meter battery exposed in the vertical sunlight for one hour will generate one unit of energy. If the sunlight is slant, the amount of energy generated should be multiplied by sinβ (β is the angle between sunlight and horizontal line).

The sun rises from the infinite far left end of the horizon at 6 o’clock and goes down at the infinite far right end of the horizon at 18 o’clock. The sun is always infinite far away. So the sunlight is parallel, and β is π/2 at 12 o′clock.

Please calculate the amount of energy generated by the battery between t1 o’clock and t2 o’clock (6 ≤t1<t2≤18 ).

Input
There are multiple test cases.
For each test case:
The first line contains two integer L(10≤L≤100,000) andN(4≤N≤1000), indicating the length of the battery and the number of pillars.
The second line contains two integers, above mentioned t1 and t2(6 ≤t1<t2≤18 ).
Then N lines follow, each containing two integers Xi(0≤Xi≤L) and Hi(1≤Hi≤1000), indicating the position and height of a pillar.

It is guaranteed that no two pillars will be in the same position. It is also guaranteed that there is a pillar on both end of the battery.
The input end with L=0, N=0.

Output
For each test case, you should output a line with the energy described above. Output should be rounded to 5 digits after decimal point.

Sample Input
10 4
14 17
0 2
5 1
8 3
10 1
0 0

Sample Output
7.97188

  • 写回答

2条回答 默认 最新

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

报告相同问题?

悬赏问题

  • ¥15 素材场景中光线烘焙后灯光失效
  • ¥15 请教一下各位,为什么我这个没有实现模拟点击
  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 保护模式-系统加载-段寄存器