Because of recent update of ZOJ, some special judges were broken. You're requested to fix the special judge for Problem 9999.
In Problem 9999, there is only one case in where the standard output is two real number x and y. The special judge uses two parameters: one is the sum of the two numbers in standard output (x and y); the other is the sum of the two numbers in the output of submitted solution (p and q). If the absolute value of the difference of these two parameters does not exceed k, the submitted solution will be accepted.
Knowing that the range of p is [0, a] and the range of q is [0, b]. What's the possibility that a solution outputting p and q with equal probability will get accepted.
Input
There are no more than 10000 test cases. You should process to the end of input. For each test case, there are only one line with 5 real numbers x, y, a, b, k, (0 <= x <= 1000, 0 <= y <= 1000, 0 <= a <= 1000, 0 <= b <= 1000, 0 <= k <= 1000).
Output
For each case, you should print out a single line indicating the possibility of getting accepted using the random solution. Your answer is supposed to be rounded to six decimal digits.
doublesolve(double x){ double ans = 0; if (x < a) ans -= x * x / 2; elseif (x >= a && x <= b){ ans -= a * a / 2; ans -= a * (x - a); }else { ans -= a * a / 2; ans -= a * (b - a); ans -= (x - b) * (a - (x - b) +a) / 2; }return ans; }
intmain(){ while(scanf("%lf %lf %lf %lf %lf", &x, &y, &a, &b, &k) != EOF){ double sum = x + y; if (dcmp(a) == 0 && dcmp(b) == 0) if(dcmp(sum - k) <= 0 && dcmp(sum + k ) >= 0) printf("1.000000\n"); elseprintf("0.000000\n"); elseif (sum + k < 0 || sum - k > a + b) printf("0.000000\n"); elseif (dcmp(a) == 0){ double minx = max(0.0, sum - k); double maxx = min(b, sum + k); printf("%0.6f\n",(maxx - minx) / b); } elseif (dcmp(b) == 0){ double minx = max(0.0, sum - k); double maxx = min(a, sum + k); printf("%0.6f\n",(maxx - minx) / a); } else { double sum1 = 0; if (a > b) swap(a, b); double yx = max(sum - k, 0.0); double yy = min(sum + k, a + b); sum1 += solve(yx); sum1 += solve(a + b - yy); printf("%.6f\n",(a * b + sum1)/ ( a * b)); } }return0; }