Bnu4078距离判定
来源:互联网 发布:apache服务启动失败 编辑:程序博客网 时间:2024/05/16 15:45
距离判定
Time Limit: 1000msMemory Limit: 65536KB 64-bit integer IO format: %lld Java class name: Main
Prev Submit Status Statistics Discuss Next
Type:
None
Tag it!
2008年杭州赛区的比赛在杭州电子科技大学举行。 北师大一行一共7人(两队+1教练)参与了这次比赛。比赛前一天,uTOPia和Archimedes的队员分开在杭电校园中闲逛,DXY作为教练,想知道他离哪一队更近。 他与某一队之间的距离定义为他离连接该队两队员的直线的距离。
Input
对于每一组数据: 第一、二行:每行两个数,表示uTOPia队队员所在位置坐标。 第三、四行:每行两个数,表示Archimedes队队员所在位置坐标。 第五行:每行两个数,表示DXY所在位置坐标。 以EOF作为结束。
Output
对于每一组数据: 第一行:离得更近的那支队伍的名称,若距离一样,输出“Equal”。
Sample Input
-1.5 0
-1.5 1.5
1.5 -1.5
1.5 0
0 0
-1.6 0
-1.6 1.5
1.5 -1.5
1.5 0
0 0
-1.5 0
-1.5 1.5
1.6 -1.5
1.6 0
0 0
Sample Output
Equal
Archimedes
uTOPia
模板
#include <iostream>#include <cstdio>#include <cmath>#include <algorithm>using namespace std;/*double PointToSegDist(double x, double y, double x1, double y1, double x2, double y2){ double cross = (x2 - x1) * (x - x1) + (y2 - y1) * (y - y1); if (cross <= 0) return sqrt((x - x1) * (x - x1) + (y - y1) * (y - y1)); double d2 = (x2 - x1) * (x2 - x1) + (y2 - y1) * (y2 - y1); if (cross >= d2) return sqrt((x - x2) * (x - x2) + (y - y2) * (y - y2)); double r = cross / d2; double px = x1 + (x2 - x1) * r; double py = y1 + (y2 - y1) * r; return sqrt((x - px) * (x - px) + (py - y1) * (py - y1));}*/double PointToSegDist(double a1,double b1,double a2,double b2,double a,double b){ if(a2!=a1) { double k=(b2-b1)/(a2-a1); return fabs((b-b1)-k*(a-a1))/sqrt(1+k*k); } else return fabs(a-a1);}int main(){ double x1,y1,x2,y2,x3,y3,x4,y4; double stx,sty; while(scanf("%lf%lf%lf%lf%lf%lf%lf%lf%lf%lf",&x1,&y1,&x2,&y2,&x3,&y3,&x4,&y4,&stx,&sty)!=EOF) { double s1=PointToSegDist(x1,y1,x2,y2,stx,sty); double s2=PointToSegDist(x3,y3,x4,y4,stx,sty); if(s1<s2) printf("uTOPia\n"); else if(s1==s2) printf("Equal\n"); else printf("Archimedes\n"); } return 0;}
0 0
- Bnu4078距离判定
- BNU4078:距离判定(点到直线的距离)
- 图像中物品距离判定
- 距离判定(点到直线的距离)
- 相似URL判定及字符串相似度距离
- 距离
- 距离
- 距离
- 距离
- 距离!
- 距离
- 距离
- 距离
- 距离
- 距离
- 距离
- 距离
- 距离
- hdoj1873 看病要排队
- poj 2505 A multiplication game
- c#枚举类型
- Particle for alexa smart home skill (1)
- MVC 视图 视图引擎 语法及渲染输出
- Bnu4078距离判定
- canvas-js贝塞尔曲线代码在线生成工具
- openstack ice版文档horizon整理(页面resize)
- 【Codeforces 526F】【JZOJ4687】奇袭
- (模板)线性筛素数
- HDU 4614 二分加线段树
- Perl语言入门
- linux下mysql自动备份
- 模拟多核,多进程构建pipe ring, 并对多个数进行排序