|
||||||||||
Horse RacingTime Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 889 Accepted Submission(s): 225 Problem Description Tian Ji likes horse racing. Once, he and QI Wei Wang agreement, to carry out a game they discuss the good, to their horses into the upper, middle and lower third-class. Due to individual differences, each horse's speed is unique. They started this game, the upper to the upper, middle to middle, lower to lower. Qi Wei WangĄ¯s horses are better than Tian Ji's horses. So Tian Ji always lost. Sun Bing Tian Ji's friends gave him an idea. He let lower to upper, upper to middle, middle to lower, as you know. Then Tian Ji won. Now Tian Ji and Qi Wei Wang host the game again, they all have n horse. As Qi Wei Wang is rich he will give some money to Tian Ji. When Qi Wei Wang lost he give 3 RMB to Tian Ji, when it is tie Qi Wei Wang gives Tian Ji 1 RMB, Of course if Tian Ji loses he would not get any money from Qi Wei Wang. Every round Tian Ji chooses a horse first, and then Qi Wei Wang chooses a horse havenĄ¯t been chosen by random. Tian Ji want you to tell him the Expectation of money he can get. Because Tian Ji has a friend named Sun Bing so he will use the best way to choose horses. Input The first line is an integer t (<=10) indicating the case number. For each case there are three lines, the first line is an integer n (<12) indicating the number of the horses. The next two lines each have n numbers, the first line is the speed of the Qi Wei WangĄ¯s horses, and the second is Tian JiĄ¯s Output For each case output a line. Only a number of expectation. 6 decimal places reserved Sample Input
Sample Output
Source | ||||||||||
|