shunfurh
编程介的小学生
2017-04-02 07:54
采纳率: 92.7%
浏览 748
已采纳

Extraordinary Tug of War

Task

In the game of "tug of war", You're fighting against an extrordinary opponent -- you two teams have exactly the same strength! Yes, this is a so-called "Mirror Match".

Imagine an x-axis along the rope, with origin at the initial position of the center of rope (COR). Then, we can APPROXIMATE the movement of the rope as follows:

In the approximation, the rope does NOT move continuously. It moves in discrete steps, step length = dt.
Every dt unit time, the rope either moves left or right, exactly sqrt(dt) unit length.
The movement of the rope in different steps are independent.
When the step length, dt, goes towards zero, the approximation above goes towards the exact movement.

It's not hard to imagine that, it usually takes too long to move COR far enough from its original position. So the referee decided to adopt a special rule: observe COR in a period of time (t1, t2). If COR keeps in one side during the whole interval, the team on that side wins. If COR had ever returned to its original position during the interval, the game ends with a draw.

The referee wants the length of the observation interval (i.e. t2-t1) be exactly L, and the probability that one of the teams wins (i.e. the game is NOT a draw) be exactly P%, when should he start to observe?

Input

The first line contains a single integer T (T <= 20), the number of test cases. Each case contains two integers L, P (1 <= L <= 1000; 0 < P < 100), explained above.
Output

For each test case, print the case number and t1, rounded to 3 decimal points.
Sample Input

2
1 50
1 10
Sample Output

Case 1: 1.000
Case 2: 0.025

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 邀请回答

1条回答 默认 最新

相关推荐