BestCoder Round #12 War(计算几何)
来源:互联网 发布:cent 7 在线音乐软件 编辑:程序博客网 时间:2024/06/18 14:04
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
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
[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 12 1 1
Sample Output
0.6666670.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<algorithm>#include<iostream>#include<string.h>#include<stdio.h>#include<math.h>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<r) { d=sqrt(r*r-hr*hr); if(hz<=d) vc=2*PI*hr*hr*hz; else { hh=min(hz,r); a=PI*r*r*hh-PI*hh*hh*hh/3; b=PI*r*r*d-PI*d*d*d/3; vc=2*(PI*hr*hr*d+a-b); } } else { if(hz<=r) vc=2*(PI*r*r*hz-PI*hz*hz*hz/3); else vc=4*PI*r*r*r/3; } vu=4*PI*r*r*r/3+PI*hr*hr*hz*2-vc; //printf("%lf %lf\n",vc,vu); printf("%.6lf\n",vc/vu); } return 0;}
2 0
- BestCoder Round #12 War(计算几何)
- BestCoder Round #62 (div.2) HDOJ5563 Clarke and five-pointed star(计算几何)
- 【HDU5563 BestCoder Round 62 (div1)A】【计算几何 凸包】Clarke and five-pointed star 正五边形判定 正五角星判定
- poj 2660 War on Weather 计算几何
- Educational Codeforces Round 11 D 计算几何
- Help him (BestCoder Round #12) HDU 5059
- 计算几何 2017.4.12
- BestCoder Round #3 BestCoder Sequence
- BestCoder Round #50 (div.2) HDU 5365 Run(简单几何)
- BestCoder Round #62 (div.2)-Clarke and five-pointed star(几何)
- “玲珑杯”ACM比赛 Round #18 A -- 计算几何你瞎暴力(计算几何)
- 【计算几何】Codeforces Round #113 (Div. 2)-B. Polygons
- 弱省胡策 Round 3 Avalon【可并堆】【计算几何】
- Educational Codeforces Round 1 F Cut Length(计算几何)
- Wunder Fund Round 2016 C. Constellation(贪心+计算几何)
- cf#Wunder Fund Round 2016 -C - Constellation-计算几何-水题
- Codeforces Round #346 (Div. 2)(D)计算几何
- Codeforces Round #357 (Div. 2) E 计算几何
- UVA - 253 Cube painting
- 简单之LPC跨进程通信(支持指针传参)
- ubuntu 下 Subversion 使用
- 【前端】Popush前端架构分析&注册后自动登录的实现
- android分享到微信朋友圈的一个回调接口的注意事项
- BestCoder Round #12 War(计算几何)
- Akka【八】 Vector Clock在AKKA中的实现
- Android反编译步骤
- 走进QT
- 架构师之路
- Eclipse的环境配置
- 屏幕坐标与客户区坐标转换
- POJ 3237 Tree 树链剖分
- stm32的串口空闲中断接收数据