​题目传送门​


题目描述

Lux has a plan to eliminate the invisible motionless enemy Teemo, whose location is detected by the Oracle Lens. She decides to cast an ultimate skill immediately, which would slay Teemo if hit because Lux has very high ability power.

Lux’s ultimate skill, Final Spark, is a powerful skill which can damage enemies by a straight beam of light with infinite length and ww meters width. It will deal damage to who shares at least a point with the light beam.

多校训练第1轮.F——Final Spark【计算几何】_oracle


But Teemo - The Swift Scout - is a well-trained soldier. He will fleetly react to the Lux’s action, and try to dodge the ray by choosing a uniformly random direction and run along the direction. Between the first action of Lux and the moment the ray finally pokes out, Lux needs time to channel the ultimate, and during the channelling Teemo can run ss meters - note that Teemo always run in a straight line.

She should choose the direction of the Final Spark before any action is taken. At the instant before Lux casting the ultimate skill using the best strategy, she wonders how possible is the skill hit Teemo. She recalls that Teemo can be recognized as a circle with radius rr meters, and now Teemo is dd meters away from Lux.

It’s very hard for Lux to calculate it. Can you answer Lux the possibility of hitting Teemo when she uses the best strategy?


输入格式

The first line contains an integer 多校训练第1轮.F——Final Spark【计算几何】_spark_02

Each test case description contains the only line with four integers, 多校训练第1轮.F——Final Spark【计算几何】_spark_03

It is guaranteed that 多校训练第1轮.F——Final Spark【计算几何】_oracle_04, so Teemo can not run through Lux, and the start of the light beam can not touch Teemo.


输出格式

For each test case, print a single number denoting the maximum possiblity on a separate line. The absolute error should not exceed 多校训练第1轮.F——Final Spark【计算几何】_ide_05

Formally, let your answer be 多校训练第1轮.F——Final Spark【计算几何】_spark_06, and the jury’s answer be 多校训练第1轮.F——Final Spark【计算几何】_oracle_07. Your answer is accepted if and only if 多校训练第1轮.F——Final Spark【计算几何】_oracle_08


输入

3
20 20 20 1000
0 0 100 1000
100 100 198 2000


输出 #1复制

1.000000000
0.000000000
0.503215306


说明/提示

In the first case of the example, Lux will shoot along the direction exactly through the center of Teemo. Teemo is unable to escape.

In the second case of the example, wherever Lux shoot, the possibility is 多校训练第1轮.F——Final Spark【计算几何】_ide_09 because the possible position of Teemo forms a circle with radius 多校训练第1轮.F——Final Spark【计算几何】_oracle_10, but the width of the ray and the diameter of Teemo are both 多校训练第1轮.F——Final Spark【计算几何】_ide_09.


题意

  • 拉克丝在距离提莫多校训练第1轮.F——Final Spark【计算几何】_ide_12
  • 提莫在拉克丝抬手的时候可以任意一个方向移动多校训练第1轮.F——Final Spark【计算几何】_oracle_13
  • 提莫视为半径为多校训练第1轮.F——Final Spark【计算几何】_ide_14的圆,拉克丝大招范围宽度为多校训练第1轮.F——Final Spark【计算几何】_oracle_15
  • 求命中提莫的概率
  • 注意:由于出题人考虑不周,输入的不是提莫的半径r,而是提莫的直径t

题解

  • 多校训练第1轮.F——Final Spark【计算几何】_oracle_16相同的数据都没有本质区别,因此可以转化为多校训练第1轮.F——Final Spark【计算几何】_ide_17的题目来做。无论以什么角
    度射入圆,我们都可以把圆旋转到激光为竖直的情况来开,因此问题就转化为用一个可水平平移的无限
    多校训练第1轮.F——Final Spark【计算几何】_oracle_16宽的长方形切一个半径为多校训练第1轮.F——Final Spark【计算几何】_oracle_13的圆能切下的最大边长。求导可知相切时边长取最大值,因此计算
    相应弧长即可。
  • 三分大师也许能通过这道题,但是太麻烦了,而且还可能被卡。
  • 如图为原始问题
  • 多校训练第1轮.F——Final Spark【计算几何】_oracle_20

  • 转变为下图问题
  • 多校训练第1轮.F——Final Spark【计算几何】_spark_21


AC-Code

#include <bits/stdc++.h>
using namespace std;

int main() {
int T; cin >> T; while (T--) {
double w, r, s, d; cin >> w >> r >> s >> d;
w += r;
if (w >= 2 * s) { cout << "1.000000000" << endl; continue; }
else if (w <= 0) { cout << "0.000000000" << endl; continue; }
else {
double a = s - w;
double theta = acos(a / s);
cout << setprecision(9) << theta / acos(-1) << endl;
}
}
return 0;
}