HDU 4617 Weapon(立体计算几何)
来源:互联网 发布:小米笔记本linux系统 编辑:程序博客网 时间:2024/05/01 22:40
Weapon
Time Limit: 3000/1000 MS (Java/Others) Memory Limit: 65535/32768 K (Java/Others)Total Submission(s): 144 Accepted Submission(s): 112
Problem Description
Doctor D. are researching for a horrific weapon. The muzzle of the weapon is a circle. When it fires, rays form a cylinder that runs through the circle verticality in both side. If one cylinder of rays touch another, there will be an horrific explosion. Originally, all circles can rotate easily. But for some unknown reasons they can not rotate any more. If these weapon can also make an explosion, then Doctor D. is lucky that he can also test the power of the weapon. If not, he would try to make an explosion by other means. One way is to find a medium to connect two cylinder. But he need to know the minimum length of medium he will prepare. When the medium connect the surface of the two cylinder, it may make an explosion.
Input
The first line contains an integer T, indicating the number of testcases. For each testcase, the first line contains one integer N(1 < N < 30), the number of weapons. Each of the next 3N lines  contains three float numbers. Every 3 lines represent one weapon. The first line represents the coordinates of center of the circle, and the second line and the third line represent two points in the circle which surrounds the center. It is supposed that these three points are not in one straight line. All float numbers are between -1000000 to 1000000.
Output
For each testcase, if there are two cylinder can touch each other, then output 'Lucky', otherwise output then minimum distance of any two cylinders, rounded to two decimals, where distance of two cylinders is the minimum distance of any two point in the surface of two cylinders.
Sample Input
330 0 01 0 00 0 15 2 25 3 25 2 310 22 -211 22 -111 22 -330 0 01 0 1.51 0 -1.5112 115 109114 112 110109 114 111-110 -121 -130-115 -129 -140-104 -114 -119.80196130 0 01 0 1.51 0 -1.5112 115 109114 112 110109 114 111-110 -121 -130-120 -137 -150-98 -107 -109.603922
Sample Output
Lucky2.32Lucky
Source
2013 Multi-University Training Contest 2
Recommend
zhuyuanchen520
比赛时发现是立体几何,没动手,后来发现是很简单的水题,看AC率那么高就知道了,只要下的了手就能过!
#include <iostream>#include <string.h>#include <stdio.h>#include <cmath>#include <algorithm>using namespace std;#define eps 1e-8#define inf 1e8#define zero(x) (((x)>0?(x):-(X))<eps)struct point3{ double x; double y; double z;}temp,temp1,temp3;struct line3{ point3 a; point3 b;}fa[300];struct plane3{ point3 a; point3 b; point3 c; double r;}po[100];point3 xmult(point3 u,point3 v){ point3 ret; ret.x=u.y*v.z-v.y*u.z; ret.y=u.z*v.x-u.x*v.z; ret.z=u.x*v.y-u.y*v.x; return ret;}double dis(point3 a,point3 b){ return sqrt((a.x-b.x)*(a.x-b.x)+(a.y-b.y)*(a.y-b.y)+(a.z-b.z)*(a.z-b.z));}double vlen(point3 p){ return sqrt(p.x*p.x+p.y*p.y+p.z*p.z);}double dmult(point3 u,point3 v){ return u.x*v.x+u.y*v.y+u.z*v.z;}point3 subt(point3 u,point3 v){ point3 ret; ret.x=u.x-v.x; ret.y=u.y-v.y; ret.z=u.z-v.z; return ret;}double linetoline(line3 u,line3 v){ point3 n=xmult(subt(u.a,u.b),subt(v.a,v.b)); return fabs(dmult(subt(u.a,v.a),n))/vlen(n);}int main(){ int t; int n,j,i; scanf("%d",&t); double min_ans; double re_dis; bool flag; while(t--) { scanf("%d",&n); for(i=0;i<n;i++) { scanf("%lf%lf%lf%lf%lf%lf%lf%lf%lf",&po[i].a.x,&po[i].a.y,&po[i].a.z,&po[i].b.x,&po[i].b.y,&po[i].b.z,&po[i].c.x,&po[i].c.y,&po[i].c.z); temp.x=po[i].c.x-po[i].a.x; temp.y=po[i].c.y-po[i].a.y; temp.z=po[i].c.z-po[i].a.z; temp1.x=po[i].b.x-po[i].a.x; temp1.y=po[i].b.y-po[i].a.y; temp1.z=po[i].b.z-po[i].a.z; temp3=xmult(temp,temp1); fa[i].a=po[i].a; fa[i].b.x=po[i].a.x+temp3.x; fa[i].b.y=po[i].a.y+temp3.y; fa[i].b.z=po[i].a.z+temp3.z; po[i].r=dis(po[i].a,po[i].b); } min_ans=inf; flag=false; for(i=0;i<n;i++) for(j=i+1;j<n;j++) { re_dis=linetoline(fa[i],fa[j]); if(re_dis<=po[i].r+po[j].r) i=n,j=n,flag=true; else if(min_ans > re_dis-po[i].r-po[j].r) min_ans=re_dis-po[i].r-po[j].r; // printf("%lf\n",re_dis); } if(flag==true) printf("Lucky\n"); else printf("%.2lf\n",min_ans); } return 0;}
- HDU 4617 Weapon(立体计算几何)
- HDU 4617 Weapon (三维计算几何)
- hdu 4617 Weapon (几何)
- Hdu 4617 Weapon (三维计算几何 异面直线距离)
- HDU 4617 Weapon (计算几何:异面直线距离)
- HDU 4617 Weapon(计算几何、三维直线距离)
- hdu 4617 Weapon(几何)
- hdu 4617 2013多校联合训练第二场weapon简单的计算几何
- ZOJ 3157 Weapon --计算几何+树状数组
- hdu 4617 Weapon 计算异面直线间距离
- hdu 4617 : Weapon
- hdu 4617 Weapon
- HDU 4617 Weapon
- HDU.4617 Weapon
- hdu 4617 Weapon【异面直线距离——基础三维几何】
- HDU 4617 Weapon 解题报告
- HDU 4617 Weapon (立体几何)
- hdu 4617 Weapon 多校第二场
- 瀑布流思路总结
- POJ 1459 Power Network
- MFC中FlexGrid控件的用法
- codeforce 113div2 20130726CF训练
- Securable 测不准
- HDU 4617 Weapon(立体计算几何)
- HDU 1257 最少拦截系统 DP
- java处理clob的几种方式
- 曼彻斯特及差分曼彻斯特编码
- 字符编码笔记:ASCII,Unicode和UTF-8
- FFMPEG的一些使用技巧
- Learning C++
- 黑马程序员 Java自学总结十三 集合框架和其他对象
- [New Portal]Windows Azure Platform (七十) TechEd 2013 North America关于Azure的最新消息