QOJ.ac

QOJ

Time Limit: 2 s Memory Limit: 512 MB Total points: 100

#52. Wreck

Statistics

There are two circles, both centered at the origin. Circle A has a radius of $a$, and Circle B has a radius of $b$.

Two points are selected uniformly at random within Circle B (meaning every point $(x, y)$ satisfying $x^2+y^2 \le b^2$ has an equal probability of being chosen). You need to find a path from one point to the other without crossing the circumference of Circle A. Calculate the infimum (shortest possible length) of such a path. If no such path exists, this value is defined as $0$.

You need to output the expected value of this path length.

Precision Requirements

Your answer must have a relative or absolute error not exceeding $10^{-3}$ to $10^{-4}$.

Specifically, since the standard solution (model solution) has a relative or absolute error of no more than $10^{-4}$, your answer will be compared against the standard solution's output with a tolerance of $10^{-3}$. Therefore, if the relative or absolute error between your output and the true value falls within the range $(10^{-3}-10^{-4}, 10^{-3}]$, it is possible (but not guaranteed) that your solution will be accepted.

Input

There are multiple test cases in a single test file.

The first line of the input contains an integer $T$, indicating the number of test cases. For each test case, the input contains a single line with two integers $a$ and $b$.

Output

For each test case, output a single line with a single real number, indicating the answer.

Example

Input

3
123 456
456 123
233 333

Output

373.30
111.37
156.84

Scoring

For all test cases, $1 \le T \le 10^5$, $1 \le a, b \le 10^6$

  • Subtask 1 (20 points): $T \le 50$, $b \le a$
  • Subtask 2 (10 points): $T \le 50$, $a = 1$, $b \ge 10^5$
  • Subtask 3 (20 points): $T \le 2$
  • Subtask 4 (20 points): $T \le 50$
  • Subtask 5 (30 points): No additional constraints.

Discussions

About Discussions

The discussion section is only for posting: Editorials, General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues. Submitting multiple issues may cause your account to be banned.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.