Chef and His Friend
All submissions for this problem are available.
Read problems statements in Mandarin Chinese and Russian.
Chef and his friend Yurii decided to meet in the cafe. As they are very busy one would not wait for another too long. Namely, after arriving, Chef will spend at most t1 seconds waiting for Yurii while Yurii will wait no more than t2 seconds.
Chef can arrive at any moment within [0..T1] with equal probability. Similarly Yurii can arrive at any moment within [0..T2].
Arrival time may be any real number from the interval.
Chef asks you to calculate the probability of meeting his friend Yurii in the cafe.
First line of the input contains an integer T denoting the number of test cases. First and the only line of each test case contains four space-separated integers – T1, T2, t1 and t2.
For each test case, output one the single real number - probability of meeting Chef and his friend Yurii. The answer will be considered correct if its absolute or relative error doesn't exceed 10-6.
- 1 ≤ T ≤ 105
- 1 ≤ T1, T2 ≤ 109
- 0 ≤ t1, t2 ≤ 109
Subtask 1: (5 points)
- t1 = 0 and t2 = 0
Subtask 2: (15 points)
- t1 = 0 or t2 = 0
Subtask 3: (25 points)
- 1 ≤ T ≤ 5
- 1 ≤ T1, T2 ≤ 10
- The answer will be considered correct if its absolute or relative error doesn't exceed 10-2
Subtask 4: (55 points)
- Original constraints
Input: 2 2 2 1 1 1 1 1 1 Output: 0.750000 1.000000
|Tags||antoniuk1, easy, frndmting, june15, maths, probability|
|Time Limit:||1 sec|
|Source Limit:||50000 Bytes|
|Languages:||C, CPP14, JAVA, PYTH, PYTH 3.6, PYPY, CS2, PAS fpc, PAS gpc, RUBY, PHP, GO, NODEJS, HASK, SCALA, D, PERL, FORT, WSPC, ADA, CAML, ICK, BF, ASM, CLPS, PRLG, ICON, SCM qobi, PIKE, ST, NICE, LUA, BASH, NEM, LISP sbcl, LISP clisp, SCM guile, JS, ERL, TCL, PERL6, TEXT, SCM chicken, CLOJ, FS|
Fetching successful submissions