#P16754. [GKS 2020 #B] Wandering Robot

    ID: 19098 远端评测题 3000ms 1024MiB 尝试: 0 已通过: 0 难度: 7 上传者: 标签>2020Special Judge概率论Google Kick Start

[GKS 2020 #B] Wandering Robot

Problem Description

Jemma is competing in a robotics competition. The challenge for today is to build a robot that can navigate around a hole in the arena.

The arena is a grid of squares containing WW columns (numbered 11 to WW from left to right) and HH rows (numbered 11 to HH from top to bottom). The square in the x-th column and y-th row is denoted (x,y)(x, y). The robot begins in the top left square (1,1)(1, 1) and must navigate to the bottom right square (W,H)(W, H).

A rectangular subgrid of squares has been cut out of the grid. More specifically, all the squares that are in the rectangle with top-left square (L,U)(L, U) and bottom-right square (R,D)(R, D) have been removed.

Jemma did not have much time to program her robot, so it follows a very simple algorithm:

  • If the robot is in the rightmost column, it will always move to the square directly below it. Otherwise,
  • If the robot is in the bottommost row, it will always move to the square directly right of it. Otherwise,
  • The robot will randomly choose to either move to the square directly to the right, or to the square directly below it with equal probability.

Jemma passes the challenge if her robot avoids falling into the hole and makes it to the square (W,H)(W, H). What is the probability she passes the challenge?

Input Format

The first line of the input gives the number of test cases, TT. TT test cases follow. Each test case consists of a single line containing WW, HH, LL, UU, RR and DD.

Output Format

For each test case, output one line containing Case #x: y, where x is the test case number (starting from 1) and y is a real number between 00 and 11 inclusive, the probability that Jemma passes the challenge.

y will be considered correct if it is within an absolute or relative error of 10510^{-5} of the correct answer. See the FAQ for an explanation of what that means, and what formats of real numbers we accept.

4
3 3 2 2 2 2
5 3 1 2 4 2
1 10 1 3 1 5
6 4 1 3 3 4
Case #1: 0.5
Case #2: 0.0625
Case #3: 0.0
Case #4: 0.3125

Hint

Limits

1T1001 \le T \le 100.

1UDH1 \le U \le D \le H.

1LRW1 \le L \le R \le W.

Neither the top-left nor bottom-right squares will be missing.

Test Set 1

1W3001 \le W \le 300.

1H3001 \le H \le 300.

Test Set 2

1W1051 \le W \le 10^5.

1H1051 \le H \le 10^5.