hdu_4717_三分_题意理解偏差
来源:互联网 发布:最流行的网络歌曲 编辑:程序博客网 时间:2024/06/06 01:28
The Moving Points
Prev Submit Status Statistics Next
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 Xi, Yi, VXi and VYi (-106 <= Xi, Yi <= 106, -102 <= VXi , VYi <= 102), (Xi, Yi) is the position of the ith point, and (VXi , VYi) is its speed with direction. That is to say, after 1 second, this point will move to (Xi + VXi , Yi + VYi).
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
2
2
0 0 1 0
2 0 -1 0
2
0 0 1 0
2 1 -1 0
Sample Output
Case #1: 1.00 0.00
Case #2: 1.00 1.00
题意:
给出n个点的 (x,y) 和 x,y方向的速度,求什求在每个时间任意两点间的最大值中的最小值;
思路:
凹函数证明,两个点什么时间会有最大距离当然是非同向走,这样两点的图像就是这样;
#include<iostream>#include<cstdio>#include<cmath>#include<string>#include<algorithm>#include<map>using namespace std;#define pi acos(-1.0)#define eps 1e-6const int inf=999999999;struct node{ double x,y,vx,vy;}inde[333];int n;double val(double t){ double ans=0; for(int i=0;i<n-1;i++) { double tx1=inde[i].x+t*inde[i].vx,ty1=inde[i].y+t*inde[i].vy; for(int j=i+1;j<n;j++) { double tx2=inde[j].x+t*inde[j].vx,ty2=inde[j].y+t*inde[j].vy; double tmp=sqrt((tx1-tx2)*(tx1-tx2)+(ty1-ty2)*(ty1-ty2)); ans=max(tmp,ans); } } return ans;}double solve(double l,double r){ while(r-l>eps) { double ll=(l+r)/2; double rr=(ll+r)/2; if(val(ll)>val(rr)) l=ll; else r=rr; } return l;}int main(){ int t,i,j; while(cin>>t) { for(int c=1;c<=t;c++) { cin>>n; for(i=0;i<n;i++) scanf("%lf%lf%lf%lf",&inde[i].x,&inde[i].y,&inde[i].vx,&inde[i].vy); double l=0.0,r=999999999.0; double time=solve(l,r); printf("Case #%d: %.2lf %.2lf\n",c,time ,val(time)); } } return 0;}
- hdu_4717_三分_题意理解偏差
- Lucky Division【理解题意】
- 【理解题意】HDU2060Snooker
- ants run 题意理解
- 地牢逃脱-理解题意
- 理解偏差、方差
- HDU3756二分或三分求满足题意的圆锥体积
- nyoj 618 追击【理解题意】
- hdu_5099 理解题意要求即可
- ccccleve_1总结 注意理解题意
- poj2709 Painter(关键在于理解题意)
- 字符串- 题意理解与转换
- hdu3400 _嵌套三分 三分求极限
- IsWow64Process函数理解的偏差
- 三分(初理解)。
- 三分算法-理解,模板
- hdu_4355_三分_学习笔记
- 题意!!!
- C# 和SQL server 中生成GUID 的方法 以及他们的之间的区别
- xlistview上下拉展示数据+点击条目选择网络+下载APK
- Some useful tips about sox rec
- 读书笔记《机器学习》:第十一章:特征选择与稀疏学习
- 【maven】Maven--java.lang.NoClassDefFoundError: org/codehaus/plexus/compiler/util/scan/InclusionScanEx
- hdu_4717_三分_题意理解偏差
- poj2796(继续学习单调栈)
- Qt软件开发文档17---自定义messagebox窗口
- Mybatis--删除
- 计算机视觉中的李群、李代数
- Python3 学习札记(五)
- Android-Selector
- 智能扫地机器人十大品牌排行
- FZU2273-Triangles