War
Time Limit: 8000/5000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 81 Accepted Submission(s): 23
Special Judge
Problem Description Long long ago there are two countrys in the universe. Each country haves its own manor in 3-dimension space. Country A's manor occupys x^2+y^2+z^2<=R^2. Country B's manor occupys x^2+y^2<=HR^2 && |z|<=HZ. There may be a war between them. The occurrence of a war have a certain probability.
We calculate the probability as follow steps.
1. VC=volume of insection manor of A and B.
2. VU=volume of union manor of A and B.
3. probability=VC/VU
Input Multi test cases(about 1000000). Each case contain one line. The first line contains three integers R,HR,HZ. Process to end of file.
[Technical Specification]
0< R,HR,HZ<=100
Output For each case,output the probability of the war which happens between A and B. The answer should accurate to six decimal places.
Sample Input
1 1 1
2 1 1
Sample Output
0.666667
0.187500
Source BestCoder Round #12
Recommend heyang | We have carefully selected several similar problems for you: 5061 5059 5058 5053 5052 题意: 给你一个球心在原点.半径为r的球和一个圆柱体。圆柱体半径为hr,高为hz然后通径为z轴.然后通径中点也在原点。 然后问你相交部分的体积
vc/体积并vu。 思路: 这题由于原点中点都在原点所以比较好做。一前还没怎么写过计算几何的题,由于最后一题不会。只有硬着头皮上了。我们就分类讨论。r,和hr的大小。然后在讨论下圆柱体有没有穿出球体。即sqrt(r*r-hr*hr)和r的大小。对于一部分的球体的体积用用定积分.积出来为PI*r*r*z-PI*z*z*z/3|上下限。 详细见代码:
#include
#include
#include
#include
#include
using namespace std; const int INF=0x3f3f3f3f; const int maxn=100010; const double PI=acos(-1.0); const double eps=1e-8; typedef long long ll; int main() { double r,hr,hz,vc,vu,d,a,b,hh; while(~scanf("%lf%lf%lf",&r,&hr,&hz)) { if(hr