The Moving Points
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).
#include <stdio.h>
#include <math.h> int N;
struct Point
{
double x,y;
double vx,vy;
}p[],a[]; double Length(Point a,Point b)
{
return sqrt((a.x-b.x)*(a.x-b.x)+(a.y-b.y)*(a.y-b.y));
}
double F(double mid)
{
for(int j=; j<N; j++)
{
p[j].x = a[j].x+p[j].vx*mid;
p[j].y = a[j].y+p[j].vy*mid;
}
double ans=-,temp;
for(int i=; i<N-; i++)
{
for(int j=i+; j<N; j++)
{
temp=Length(p[i],p[j]);
if(ans<temp) ans=temp;
}
}
return ans;
}
int main()
{
int T,i,k,L,cnt=;
scanf("%d",&T);
while(T--)
{
scanf("%d",&N);
for(i=; i<N; i++)
{
scanf("%lf %lf %lf %lf",&p[i].x,&p[i].y,&p[i].vx,&p[i].vy);
a[i].x=p[i].x,a[i].y=p[i].y;
a[i].vx=p[i].vx,a[i].vy=p[i].vy;
}
k=;
double l=,r=1000.0,mid1,mid2;
while(k--)
{
mid1 = l +(r-l)/;
mid2 = r-(r-l)/;
if(F(mid1)<F(mid2)) r=mid2;
else l=mid1;
}
printf("Case #%d: %.2lf %.2lf\n",++cnt,l,F(l));
} return ;
}
HUD 4717
The Moving Points的更多相关文章
- 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 ...
- The Moving Points hdu4717
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 ...
- HDU-4717 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的題目更容易 ...
- The Moving Points HDU - 4717
There are N points in total. Every point moves in certain direction and certain speed. We want to kn ...
- HDU 4717 The Moving Points(三分法)(2013 ACM/ICPC Asia Regional Online ―― Warmup2)
Description There are N points in total. Every point moves in certain direction and certain speed. W ...
随机推荐
- hadoop基本命令1
(大讲台——国内首个it在线混合式自适应学习平台,轻量级的高薪就业和技能提升解决方案) 1.列出所有Hadoop Shell支持的命令$ bin/hadoop fs -help2.显示关于某个命令的详 ...
- jquery 验证插件 validate
1)required:true 必输字段(2)remote:"check.php" 使用ajax方法调用check.php验证输入值(3)email:true 必须输入正确格式的电 ...
- RAC,客户端连接失败ORA-12514
今天上午,某项目运维组的同事过来求助:"某系统的应用有问题了,WEB页面打开以后出现ORACLE的ORA-12514错误,貌似监听有问题了!" 该系统的数据是采用RAC部署的模式, ...
- 20 个最棒的 jQuery Tab 插件
jQuery Tab 常用来做网页上的选项设置界面和导航,本文向你推荐最棒的 20 个 jQuery Tab 插件.Enjoy !! 1. Slider Tabs SliderTabs 是一个可定制的 ...
- 关于size_t与size_type
整理自关于size_t与size_type 问题起源于这样一段代码: #include <algorithm> #include <stdio.h> int main() { ...
- unity 与 android 协调工作 注意事项
原地址:http://blog.csdn.net/u012085988/article/details/17436191 1.unity调android函数 AndroidJavaClass jc = ...
- TSS 任务状态段
TSS(任务状态段) 1 什么是TSS TSS 全称task state segment,是指在操作系统进程管理的过程中,任务(进程)切换时的任务现场信息. 2 TSS工作细节 TSS在任务切换过程 ...
- UVA 10765 Doves and bombs
给定一个无向的连通图,要求每个点去掉后连通分量的数目,然后输出连通分量最多的m个点. 分析: 先求出双连通分量,然后统计所有双连通分量中割顶出现的次数,最后求出的就是割顶去掉后剩下的双连通的数目,对于 ...
- easyui源码翻译1.32--Tabs(选项卡)
前言 使用$.fn.tabs.defaults重写默认值对象.下载该插件翻译源码 选项卡显示一批面板.但在同一个时间只会显示一个面板.每个选项卡面板都有头标题和一些小的按钮工具菜单,包括关闭按钮和其他 ...
- ANDROID_MARS学习笔记_S01原始版_002_实现计算乘积及menu应用
一.代码 1.xml(1)activity_main.xml <RelativeLayout xmlns:android="http://schemas.android.com/apk ...