Tobby and the line game

Tobby the pet enjoys a lot going to the circus and he likes to take part in the games available for smart pets like him. This time a new circus has just arrived to Tobby’s town and they are promoting a new game called the line game. The line game is a very simple game played over a rectangular field whose lower left corner is pL = (xL, yL) and its upper right corner is pR = (xR, yR). In one game there are multiple players and each of them have to throw two coins over the game field. The game’s goal is to make the line joining the places where the two coins landed as large as possible. The player who manages to make the longest line from his threw coins is the winner of the game and therefore the winner of a big prize as well. Tobby has been watching some rounds of the line game and he is wondering which are the chances for him to win this game. He knows that he can barely throw the coins with his dog’s paws so it can be assumed that all the points over the game field are equally probable for the coins to land and it can also be assumed that the two throws are independent. However, Tobby is so skilled that you can be sure his coins will always land inside the game field or over its boundaries. Tobby wants to compute the expected value of the squared length of the resulting line since this result can help him to make a choice about whether or not he should take part in the line game. Can you help him? For this problem the coin landing locations can be assumed to be 2D points over a continuous plane. Suppose that the first coin landed at p1 = (x1, y1) and the second at p2 = (x2, y2) so Tobby is interested in computing the expectation over ∥p1 − p2∥2 = (x1 − x2)2 + (y1 − y2)2. Input The input file contains several test cases. Each test case comprises 4 integer numbers, namely xL, yL, xR and yR which represent the rectangular field as described above. The end of the input file will be given by EOF. Constraints: • −500 ≤ xL,yL,xR,yR ≤ 500 • xL < xR • yL < yR Output Print one number, the required expected value. The absolute error of your answer should not be greater than 10−5. Sample Input -100 -50 23 400 0 0 500 1 Sample Output 36271.5 41666.833333333314