8673: Mocha and Railgun

内存限制:128 MB 时间限制:1 S 标准输入输出
题目类型:传统 评测方式:文本比较 上传者:
提交:12 通过:0

题目描述


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 on the circular wall will be destroyed if and only if it meets the following conditions:

  1. The projection of point PPP on line ABABAB lies on the segment ABABAB (inclusive).
  2. A,B,PA,B,PA,B,P make a counterclockwise turn, that is to say AB→×AP→>0\overrightarrow{AB} \times \overrightarrow{AP} > 0AB×AP>0.

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 α\alphaα 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 to the wall C is greater than ddd.

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 (1T105) — the number of test cases.
In each test case, the first line is an integer r (1r109) — the radius of the circular wall C.
The next line contains three integers xQ,yQ,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 10^{-6}

输入样例 复制

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.