ARAM (Large)

Decide when to spend reroll currency on random champions to maximize the long-run win rate over many games.

Hard8Dynamic programmingProbabilityBinary searchSortingNo attempts yetTime limit120sMemory limit512 MB

Problem

League of Legends™ has a game mode called ARAM, short for All Random, All Mid. This problem uses a simplified version of its rules, so you do not need to have played the game.

Every time you start an ARAM game, one of NN champions is assigned to you uniformly at random. Your chance of winning depends on the champion, so an unlucky draw leaves you wishing for a different one. The game has a reroll function.

The right to reroll works like money. Before your first game you start with RR RD (reroll dollars). You can reroll only while you hold at least 11 RD, and each reroll costs 11 RD. After every game you gain 1/G1/G RD, where GG is an integer, but your RD never goes above RR. If you play a game while holding RR RD, you still hold RR RD when that game ends.

While you hold at least 11 RD, choosing to reroll spends 11 RD and assigns you one of the NN champions uniformly at random again. The champion you already had can come up again. If you dislike the champion you rerolled into and still hold at least 11 RD, you can reroll again. You can keep rerolling as long as you hold at least 11 RD.

For example, take R=2R = 2 and G=2G = 2 and suppose you use one reroll in your first game. After that game you hold 1.51.5 RD. If you play the next game without rerolling, you hold 2.02.0 RD after it. If you play another game without rerolling, you still hold 2.02.0 RD, because you cannot go above R=2R = 2. If you use two rerolls in the game after that, you hold 0.50.5 RD once it ends.

You are given the list of champions and the probability that you win a game played with each of them. Compute the expected fraction of wins when you play 1010010^{100} games and choose your strategy optimally. The count 1010010^{100} is large enough that the answer agrees, to nine digits after the decimal point, with the largest long run average of the expected win probability per game.

Input

The first line contains the number of test cases TT. Then TT test cases follow. The first line of each test case contains three space separated integers NN, RR and GG. The next line contains NN space separated real numbers P1,P2,,PNP_1, P_2, \dots, P_N, where PiP_i is the probability that you win a game played with champion ii.

Output

For each test case, print one line in the form Case #x: y, where xx is the test case number starting from 11 and yy is the expected fraction of games you win over 1010010^{100} games. Round yy and print exactly nine digits after the decimal point.

Constraints

  • 1T1001 \le T \le 100
  • 1N10001 \le N \le 1000
  • 1R201 \le R \le 20
  • 1G201 \le G \le 20
  • 0.0Pi1.00.0 \le P_i \le 1.0
  • PiP_i is given as one digit, a decimal point, then four digits.

Note

League of Legends is a trademark of Riot Games. Riot Games does not endorse this problem and has no involvement with it.