编程介的小学生 2019-08-23 23:50 采纳率: 20.5%
浏览 94

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

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 Oracle触发器记录修改前后的字段值
    • ¥100 为什么这个恒流源电路不能恒流?
    • ¥15 有偿求跨组件数据流路径图
    • ¥15 写一个方法checkPerson,入参实体类Person,出参布尔值
    • ¥15 我想咨询一下路面纹理三维点云数据处理的一些问题,上传的坐标文件里是怎么对无序点进行编号的,以及xy坐标在处理的时候是进行整体模型分片处理的吗
    • ¥15 CSAPPattacklab
    • ¥15 一直显示正在等待HID—ISP
    • ¥15 Python turtle 画图
    • ¥15 stm32开发clion时遇到的编译问题
    • ¥15 lna设计 源简并电感型共源放大器