405237: GYM101856 A Assessments

Memory Limit:1024 MB Time Limit:3 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

A. Assessmentstime limit per test3 secondsmemory limit per test1024 megabytesinputassessment.inoutputstandard output

As the World Cup approaches, FIFA is holding a worldwide assessment of players. In each assessment, we have a line of N distinct players, the players are standing in the order 0, 1, ..., N - 1. The assessment is carried out in k rounds, in each round the players run for a long time. When they finish the round, it sometimes happens (with probability p) that exactly one pair of adjacent players end up swapping their positions; this pair of adjacent players occurs randomly with equal chance. FIFA wants your help finding out the probability that the final state after the k rounds will have the players x and y swapped.

Input

The first line of the input contains a single integer 1 ≤ T ≤ 100 the number of test cases. Each test case consists of one line that contains 5 space separated numbers N, p, x, y, k; where 1 ≤ N ≤ 50 is the number of players, 0 ≤ x, y < N are the numbers of the players of the query, 0 ≤ k ≤ 3000 is the number of rounds of the assessment, and p is a floating point number 0.0 ≤ p ≤ 1.0.

Output

For each test case, output a single line displaying the case number and the answer probability rounded to exactly 5 decimal places.

ExampleInput
3
4 1.0 1 1 2
4 0.0 0 2 1
2 0.5 0 1 1
Output
Case 1: 0.33333
Case 2: 0.00000
Case 3: 0.50000

加入题单

上一题 下一题 算法标签: