F.A.Q
Hand In Hand
Online Acmers
Problem Archive
Realtime Judge Status
Authors Ranklist
 
     C/C++/Java Exams     
ACM Steps
Go to Job
Contest LiveCast
ICPC@China
Best Coder beta
VIP | STD Contests
    DIY | Web-DIY beta
Author ID 
Password 
 Register new ID

Horse Racing

Time 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
2 2 1 2 3 4 2 1 4 2 3
 

Sample Output
6.000000 3.000000
 

Source
 

Statistic | Submit | Discuss | Note
Hangzhou Dianzi University Online Judge 3.0
Copyright © 2005-2024 HDU ACM Team. All Rights Reserved.
Designer & Developer : Wang Rongtao LinLe GaoJie GanLu
Total 0.000000(s) query 1, Server time : 2024-11-22 15:20:40, Gzip enabled