F.A.Q
Hand In Hand
Online Acmers
Problem Archive
Realtime Judge Status
Authors Ranklist
 
     C/C++/Java Exams     
ACM Steps
Go to Job
Contest LiveCast
ICPC@China
Best Coder beta
VIP | STD Contests
    DIY | Web-DIY beta
Author ID 
Password 
 Register new ID

Battery

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 299    Accepted Submission(s): 89


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
 

Source
 

Statistic | Submit | Discuss | Note
Hangzhou Dianzi University Online Judge 3.0
Copyright © 2005-2024 HDU ACM Team. All Rights Reserved.
Designer & Developer : Wang Rongtao LinLe GaoJie GanLu
Total 0.000000(s) query 1, Server time : 2024-11-23 00:36:34, Gzip enabled