logo AlgoBeat OnlineJudge
登录 注册

#216675. [GKS 2018 #E] Board Game

内存限制:1024 MiB 时间限制:30000 ms 标准输入输出
题目类型:VJudge(洛谷) 评测方式:VJudge
上传者: 匿名

题目描述

Bahu is playing a board game with Bala. Each player has army cards with various strength values. There are battlefields in the game. Each player must distribute their cards among the battlefields, face down, such that each battlefield gets exactly of their cards.

When the game begins, all cards will be revealed. For each battlefield, each player sums up the strength values of their cards in that battlefield, and then the players compare those totals. If one player has a higher total, that player wins that battlefield. If the totals are the same, Bala wins that battlefield; this is his special advantage.

The overall winner of the game is the player who wins the most battlefields. (Since there are battlefields, it is guaranteed that there will not be an overall tie.)

Bala thinks that his advantage is enough to make him win, so he just randomly shuffles his cards and puts the first on the first battlefield, the next on the second battlefield, and the last on the third battlefield.

Even though Bahu is at a disadvantage, he is still going to try to win! Find the probability that he will win if he distributes his cards optimally. Note that all Bala's cards are faced down so Bahu must choose the distribution of his cards before seeing the distribution of Bala's cards.

输入格式

The first line of the input gives the number of test cases, . test cases follow; each consists of three lines. The first line contains an integer , as described above. The second line contains integers , representing the strength values of Bahu's cards. The third line consists of integers , representing the strength values of Bala's cards.

输出格式

For each test case, output one line containing Case #x: y, where x is the test case number (starting from 1) and y is the probability described above. y will be considered correct if it is within an absolute or relative error of of the correct answer.

样例

样例输入 1

2
3
2 2 2 2 2 2 2 3 3
2 2 2 2 2 2 2 2 2
3
2 2 2 2 2 2 2 3 3
2 2 2 2 2 2 2 2 3

样例输出 1

Case #1: 1.000000000
Case #2: 0.333333333

数据范围与提示

In Sample Case #1, Bahu can put cards (, , ) in first battle field, (, , ) in second battle field and (, , ) in third battle field. As all Bala's cards are , Bala wins the first battle field and Bahu wins the second and third battle field.

Limits

.

, for all .

, for all .

Small dataset (Test set 1 - Visible)

.

Large dataset (Test set 2 - Hidden)

.