No.605 Sphere Caught in Between
Problem Statement
There is a sphere \(S : x^2+y^2+z^2=1 \) of radius \(1\) centered at the origin.
There are also two planes \( P_1 : x=a , P_2 : x=b \) perpendicular to the \(x\)-axis.
Find the area of the part of the sphere \(S\) that lies between the two planes \(P_1, P_2\).
An absolute or relative error of about \(10^{-6}\) is allowed.
Note 1: You are asked for the "area", not the "volume"!
Note 2: The area of the "cross section" has nothing to do with this!
Input
\(a\) \(b\)
\(-1 \le a \lt b \le 1 \)
\(a, b\) are given to 4 decimal places.
Output
Output on one line the area of the part of the sphere \(S\) that lies between the two planes \(P_1, P_2\).
An absolute or relative error of about \(10^{-6}\) is allowed.
Sample
Sample 1
Input
-1.0000 1.0000
Output
12.56637061
This is the area of the entire sphere \(S\), so the answer is \(4 \pi\).
Sample 2
Input
0.0000 1.0000
Output
6.28318531
This is exactly half the area of the sphere \(S\), so the answer is \(2 \pi\).
提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。
tails
はむこ