Mocha and Railgun
题号:NC239323
时间限制:C/C++/Rust/Pascal 1秒,其他语言2秒
空间限制:C/C++/Rust/Pascal 256 M,其他语言512 M
Special Judge, 64bit IO Format: %lld

题目描述

There is a candy store near Mocha's school. It's said that the storekeeper, Dagashiya, can cast the railgun spell. To be the most powerful Mahou Shoujo, Mocha asks Dagashiya to teach her the railgun spell.

To test her mastery of this spell, Mocha creates a circular wall C whose center is (0,0). The railgun spell has a base segment AB with length 2d. When it is cast, a point P on the circular wall will be destroyed if and only if it meets the following conditions:

  1. The projection of point P on line AB lies on the segment AB (inclusive).
  2. A,B,P make a counterclockwise turn, that is to say .

Mocha chooses a point Q which strictly lies in the circle and sets Q as the center of the base segment. Then Mocha will choose an angle arbitrarily and rotate the base segment around Q by . Because Mocha is a rookie of the spell, the endpoints of the base segment will always lie in C strictly, which means the distance from Q to the wall C is greater than d.

Mocha wants to know the maximum length of the wall that can be destroyed in one cast.

You can see the note for better understanding.

输入描述:

The first line is an integer T () — the number of test cases.

In each test case, the first line is an integer r () — the radius of the circular wall C.

The next line contains three integers x_Q,y_Q,d — the coordinates of the point Q and a half of the length of the base segment.

输出描述:

For each test case, print a real number in a single line, denoting the maximum length of the wall that Mocha can destroy in one cast. Your answer will be considered equal to the correct answer when their absolute or relative error doesn't exceed .
示例1

输入

复制
1
2
0 0 1

输出

复制
2.094395102393

备注:

In the picture above, the blue lines are the boundaries of the railgun spell. The red arc is the wall being destroyed.