Meeting
[Description]
SprayAnd Ray want to meet at some time between X and Y, but neither of them is very punctual ...... Therefore, they did not agree on the exact time of the meeting. But they discussed it well. If anyone arrives first, they will wait for the other party for Z minutes. However, both of them will appear at a certain time between X and Y, but they may not be met.
Now, calculate the probability of meeting the two of them.
[Input format]
Multiple groups of test data are input.
Each group of test data contains two integers X and Y (0 <= x <y <= 24) and a real Z (0 <Z <= 60 * (Y-X ))
[Output format]
For each group of test data
Output a row, which is the calculated probability. Keep the last six digits of the decimal point, and round the number of 7th digits.
[Input example]
11 12 20
[Output example]
0.555556
Analysis:
The solution to this question is to use the mathematical knowledge of linear programming,
But there is a more magical way,
Here is a brief introduction ..
First, this is the case,
Set a t variable, t = z/(y-x) * 60)
Then, the solution is obtained directly by ans = (1-t) * t + t...
Pretty cool...
Use the diagram to explain...
,
First, we may wish to set the first person to arrive at the' moment ~ B 'the person who arrives at the moment (y time) will surely meet the person who arrives at the first arrival. In this case, the probability of the person who meets is z/(y-x) * 60) {Note: The previously set t}
{Note: The probability here is the first person in '~ The probability of arriving between BITs}
Next, let's assume that,
First served by ~ The probability of arrival between B is (1-T)
The probability that the next person will arrive within the range they can meet is t.
In this case, the probability of their encounter is (1-t) * t
To sum up, ans = (1-t) * t + t
Check the code. The exception is concise.
program meeting; var i,j,n,m,k,l:longint; x,y,z,t,ans:real; begin assign(input,'meeting.in'); reset(input); assign(output,'meeting.out'); rewrite(output); while not eof do begin readln(x,y,z); t:=z/((y-x)*60); ans:=(1-t)*t+t; writeln(ans:0:6); end; close(input); close(output); end.