题目传送门
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.
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 T ( 1 ≤ T ≤ 1 0 5 ) T(1 \leq T \leq 10 ^ 5) T(1≤T≤105) - the number of test cases.
Each test case description contains the only line with four integers, w , t , s , d ( 0 ≤ w , r , s ≤ 1000 , 1 ≤ d ≤ 3000 ) w,t,s,d (0 \leq w, r, s \leq 1000, 1 \leq d \leq 3000) w,t,s,d(0≤w,r,s≤1000,1≤d≤3000) - the width of light beam, diameter of Teemo, the distance Teemo can run during Lux channelling her Final Spark, the distance between Lux and Teemo.
It is guaranteed that w + t + s < d w+t+s
For each test case, print a single number denoting the maximum possiblity on a separate line. The absolute error should not exceed 1 0 − 6 10 ^ {-6} 10−6 .
Formally, let your answer be A A A, and the jury’s answer be B B B. Your answer is accepted if and only if ∣ A − B ∣ ≤ 1 0 − 6 |A-B| \leq 10 ^ {-6} ∣A−B∣≤10−6
3
20 20 20 1000
0 0 100 1000
100 100 198 2000
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 0 0 0 because the possible position of Teemo forms a circle with radius 100 100 100, but the width of the ray and the diameter of Teemo are both 0 0 0.
#include
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;
}