#Lutece0561. Game
Game
Migrated from Lutece 561 Game
All parts of this problem, including description, images, samples, data and checker, might be broken. If you find bugs in this problem, please contact the admins.
Description
Today, Alice and Bob decide to go for a tour. Before they start, they find that they have to take a lot of things and neither of them wants to do it. So they plan to play a game and the loser takes things. The game as followings:
- First step : they write down integers together. The n integers form a sequence .
- Second step : Alice writes down an integer (), and Bob writes down an integer ()
- Third step : Alice randomly choose a consecutive subsequece from . Any subsequence containing at least numbers could be chosen. Name the smallest number of this subsequence as . Bob does the same thing and the smallest number of his subsequence is named .
Alice wins the game if is larger than . Bob wins if is larger. If equals , Alice and Bob would toss a coin to decide who wins. In this case, the probability for each of them to win is .
Now, they have written down integers. Alice gets the number and Bob gets the number . Alice wonders the probability for him to win the game.
Input
There are multiple test cases. The first line of the input will be an integer () indicating the number of test cases.
For each case, the first line is an integer () - the number of integers. The second line contains integers wrote down in the first step. The absolute value of those integers are all less than . The third line are two integers and .
Output
For each test case, print Case #t: r
in a single line, in which t is the number of the test case starting from , and is a single real number (rounded to six decimal place), which represents the win probability of Alice.
Samples
2
3
2 2 3
3 2
3
1 2 3
2 1
Case #1: 0.833333
Case #2: 0.750000
Note
In the first case, the segment Alice chooses is .The segments Bob may choose are , , with the same probability of and their second number if sorted are . So the answer is $\frac{1}{3}+\frac{1}{3}+\frac{1}{3}\times\frac{1}{2}=\frac{5}{6}$.
Resources
10th UESTC Programming Contest Preliminary