编程介的小学生 2019-12-31 18:08 采纳率: 20.5%
浏览 88

Horse Racing 起码问题算法

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

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 c程序不知道为什么得不到结果
    • ¥40 复杂的限制性的商函数处理
    • ¥15 程序不包含适用于入口点的静态Main方法
    • ¥15 素材场景中光线烘焙后灯光失效
    • ¥15 请教一下各位,为什么我这个没有实现模拟点击
    • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
    • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
    • ¥20 有关区间dp的问题求解
    • ¥15 多电路系统共用电源的串扰问题
    • ¥15 slam rangenet++配置