The Moving Points hdu4717
The Moving Points
Time Limit: 6000/3000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 964 Accepted Submission(s): 393
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).
2
0 0 1 0
2 0 -1 0
2
0 0 1 0
2 1 -1 0
Case #2: 1.00 1.00
#include <iostream>
#include <string.h>
#include <stdio.h>
#include <math.h>
#include <algorithm>
using namespace std;
#define eps 0.000001
typedef struct abcd
{
double x,y,vx,vy;
} point;
point p[];
int n;
double dis(double tt,int x,int y)
{
double xx=p[x].x+tt*p[x].vx;
double yy=p[x].y+tt*p[x].vy;
double xx1=p[y].x+tt*p[y].vx;
double yy1=p[y].y+tt*p[y].vy;
return sqrt((xx-xx1)*(xx-xx1)+(yy-yy1)*(yy-yy1));
}
double funa(double tt)
{
int i,j;
double maxa=;
for(i=;i<n;i++)
{
for(j=i+;j<n;j++)
{
maxa=max(maxa,dis(tt,i,j));
}
}
//cout<<tt<<endl;
return maxa;
}
double fun()
{
double l=,r=,m1,m2;
while(r-l>eps)
{
m1=l+(r-l)/;
m2=r-(r-l)/;
if(funa(m1)<funa(m2))
{
r=m2;
}
else l=m1;
}
return l;
}
int main()
{
int t,i,j,k;
scanf("%d",&t);
for(i=; i<=t; i++)
{
scanf("%d",&n);
for(j=; j<n; j++)
{
scanf("%lf%lf%lf%lf",&p[j].x,&p[j].y,&p[j].vx,&p[j].vy);
}
double yyy=fun();
printf("Case #%d: %.2lf %.2lf\n",i,yyy,funa(yyy));
}
}
The Moving Points hdu4717的更多相关文章
- HDU-4717 The Moving Points(凸函数求极值)
The Moving Points Time Limit: 6000/3000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others ...
- HDOJ 4717 The Moving Points
The Moving Points Time Limit: 6000/3000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others ...
- HDU 4717The Moving Points warmup2 1002题(三分)
The Moving Points Time Limit: 6000/3000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others ...
- HDU 4717 The Moving Points (三分)
The Moving Points Time Limit: 6000/3000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others ...
- HDUOJ---The Moving Points
The Moving Points Time Limit: 6000/3000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others ...
- F. Moving Points 解析(思維、離散化、BIT、前綴和)
Codeforce 1311 F. Moving Points 解析(思維.離散化.BIT.前綴和) 今天我們來看看CF1311F 題目連結 題目 略,請直接看原題. 前言 最近寫1900的題目更容易 ...
- ACM学习历程—HDU4717 The Moving Points(模拟退火 || 三分法)
Description There are N points in total. Every point moves in certain direction and certain speed. W ...
- hdu4717 The Moving Points(二分做法)
这道题看了大家都是用三分做的,其实这道题也是可以用二分来做的,就是利用一下他们的单调性. 对于N个点,总共要考虑N(N+1)/2个距离,距离可以用二次函数表示,而且开口都是向上的. 下面具体说一下二分 ...
- hdu4717 The Moving Points 三分法
题意:坐标系上有n个点,每个点的坐标和移动方向速度告诉你,速度方向都是固定的.然后要求一个时刻,使得这个时刻,这些点中最远的距离最小. 做法:三分法,比赛的时候想不到.考虑两个点,如果它们走出来的路径 ...
随机推荐
- 新的表格展示利器 Bootstrap Table Ⅱ
上一篇文章介绍了Bootstrap Table的基本知识点和应用,本文针对上一篇文章中未解决的文件导出问题进行分析,同时介绍BootStrap Table的扩展功能,当行表格数据修改. 1.B ...
- Ext.data.Store添加动态参数
多条件查询页面的参数都是动态的,并且我们通常还会有默认加载页面.此时,动态添加参数非常重要,其中baseparam是解决问题的关键. @ 将查询条件定义为一个全局变量 var param_01 = & ...
- 关于本地代码挂载到vm虚拟环境下运行
第一步: 首先你得装个 VM 虚拟机 然后新建一个Linux虚拟环境(建议CentOS镜像)(PS:至于安装此处就省略.....) 第二步:启动虚拟机配置 lnmp (这里我们可以使用 lnmp的 ...
- jQuery的基础跟JS的正则
大家好,我是唯芸星,这是我的一点点学过的知识,呈现给大家 1:正则表达式 包括: 1:正则表达式包括两部分 ①:定义正则表达式的规则 ②:正则表达式的规模(i/g/ ...
- CSS 中的 initial、inherit、unset、revert
在css中,initial(初始).inherit(继承).unset(未设置).revert(还原)这四个关键字可以应用于所有的CSS属性. initial - 初始默认值.IE不支持 inheri ...
- JVM中锁优化,偏向锁、自旋锁、锁消除、锁膨胀
详见:http://blog.yemou.net/article/query/info/tytfjhfascvhzxcyt364 本文将简单介绍HotSpot虚拟机中用到的锁优化技术. 自旋锁 互斥同 ...
- WPF--鼠标右键菜单中的Command命令实现
一个功能,在ListView中的ListBoxItem控件上实现右键菜单关闭选项,将该ListBoxItem从ListView中删除. 利用 RoutedCommand类创建Command命令,MSD ...
- CCNP-3.vlan间路由及三层交换机的配置
- 201521123098 《Java程序设计》 第5周学习总结
1. 本周学习总结 1.1 尝试使用思维导图总结有关多态与接口的知识点. 1.2 可选:使用常规方法总结其他上课内容. 1. 对接口这一定义有了初步的了解: 2. 学习了如何定义实现类和如何实现一些接 ...
- Win8打开chm右侧空白解决方法
Win8下打开CHM文件,左侧有目录,但是右侧空白.而且打开的时候,还弹出很多IE窗口. 感觉应该不是文件本身的问题.下面是我的解决方法,其他系统也可以试一试. 最初打开文件如下 首先:1,右键关联c ...