hdoj4717The Moving Points【三分】
来源:互联网 发布:新大洋知豆电动汽车 编辑:程序博客网 时间:2024/05/17 04:53
B - The Moving Points
Time Limit:3000MS Memory Limit:32768KB 64bit IO Format:%I64d & %I64uDescription
There are N points in total. Every point moves in certain direction and certain speed. We want to know at what time that the largest distance between any two points would be minimum. And also, we require you to calculate that minimum distance. We guarantee that no two points will move in exactly same speed and direction.
Input
The rst line has a number T (T <= 10) , indicating the number of test cases.
For each test case, first line has a single number N (N <= 300), which is the number of points.
For next N lines, each come with four integers X i, Y i, VX i and VY i (-10 6 <= X i, Y i <= 10 6, -10 2 <= VX i , VY i <= 10 2), (X i, Y i) is the position of the i th point, and (VX i , VY i) is its speed with direction. That is to say, after 1 second, this point will move to (X i + VX i , Y i + VY i).
For each test case, first line has a single number N (N <= 300), which is the number of points.
For next N lines, each come with four integers X i, Y i, VX i and VY i (-10 6 <= X i, Y i <= 10 6, -10 2 <= VX i , VY i <= 10 2), (X i, Y i) is the position of the i th point, and (VX i , VY i) is its speed with direction. That is to say, after 1 second, this point will move to (X i + VX i , Y i + VY i).
Output
For test case X, output "Case #X: " first, then output two numbers, rounded to 0.01, as the answer of time and distance.
Sample Input
220 0 1 02 0 -1 020 0 1 02 1 -1 0
Sample Output
Case #1: 1.00 0.00Case #2: 1.00 1.00
提议给出一些点和他们的速度求使他们任意两点间的距离的最大值最小
#include<cstdio>#include<cstdlib>#include<cstring>#include<cmath>#include<algorithm>#define eps 1e-8using namespace std;struct point{double x,y,vx,vy;}A[310];int n;double MAX(double a,double b){return a>b?a:b;}double MIN(double a,double b){return a<b?a:b;}double dist(point a,point b){return sqrt((a.x-b.x)*(a.x-b.x)+(a.y-b.y)*(a.y-b.y));}double distmin(double t){double max=0;for(int i=0;i<n;++i){for(int j=i+1;j<n;++j){point a,b;a.x=A[i].x+t*A[i].vx;a.y=A[i].y+t*A[i].vy;b.x=A[j].x+t*A[j].vx;b.y=A[j].y+t*A[j].vy;max=MAX(max,dist(a,b));}}return max;}int main(){int t,i,j,k=1;scanf("%d",&t);while(t--){scanf("%d",&n);for(i=0;i<n;++i){scanf("%lf%lf%lf%lf",&A[i].x,&A[i].y,&A[i].vx,&A[i].vy);}int size=100;double left=0,right=10000;while(size--){double mid=(left+right)/2;double mmid=(mid+right)/2;if(distmin(mid)<distmin(mmid)){right=mmid;}else {left=mid;}}printf("Case #%d: %.2lf %.2lf\n",k++,left,distmin(left));}return 0;}
0 0
- hdoj4717The Moving Points【三分】
- hdu4717 The Moving Points 三分
- HDU 4717 The Moving Points(三分枚举)
- HDOJ 4747 - The Moving Points 三分搜索...
- hdu 4717 - The Moving Points(三分)
- hdu 4717 The Moving Points(三分)
- HDU 4717 The Moving Points(三分)
- hdu 4717 The Moving Points(三分)
- The Moving Points -HDU 4717 三分
- hdu 4717 The Moving Points(三分)
- HDU 4717 The Moving Points (三分)
- HDU 4717 The Moving Points (三分枚举)
- HDU 4717 The Moving Points 水三分
- hdu-4717-The Moving Points三分
- HDU4717 The Moving Points(三分)
- hdu 4717 The Moving Points(三分,4级)
- HDU 4717The Moving Points warmup2 1002题(三分)
- HDU 4717 The Moving Points (三分搜索)
- 最强时间验证包括闰年验证
- hdoj4716A Computer Graphics Problem
- 半个月实习小结
- 安卓如何获取屏幕宽度极其分辨率
- 静态方法和静态成员变量
- hdoj4717The Moving Points【三分】
- iOS开发小技巧(一)
- 安卓中的事务
- android给View设置边框 填充颜色 弧度
- 今天的学习和生活2015/10/31
- C++字符串2——字符串构造
- gnome3 去除标题栏
- springMVCs下载
- CentOS为firefox安装flash插件