405237: GYM101856 A Assessments
Description
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.
InputThe 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.
OutputFor each test case, output a single line displaying the case number and the answer probability rounded to exactly 5 decimal places.
ExampleInput3Output
4 1.0 1 1 2
4 0.0 0 2 1
2 0.5 0 1 1
Case 1: 0.33333
Case 2: 0.00000
Case 3: 0.50000