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 ...
随机推荐
- 算法之插入排序(inertionSort)
插入排序的基本操作就是将一个数据插入到已经排好序的有序数据中,从而得到一个新的.个数加一的有序数据,适用于少量数据的排序,时间复杂度为O(n^2). 插入排序属于稳定排序. 插入排序不需要构造新的数据 ...
- css3太极图效果+自动旋转
主要使用border-radius属性实现圆,半圆,定位坐标覆盖部分模块. 半圆: width: 50%; height: 100%; border-radius:100% 0 0 100% /50% ...
- Android NFC标签 开发深度解析 触碰的艺术
有几天没有更新博客了,不过本篇却准备了许久,希望能带给每一位开发者最简单高效的学习方式.废话到此为止,下面开始正文. NFC(Near Field Communication,近场通信)是一种数据传输 ...
- linux下tomcat的安装
本文主要内容: (1)安装apr,这是 Apache 为了提升 Tomcat 的性能搞的一套本地化 Socket, Thread, IO 组件也就是说它有高级 IO 功能, 操作系统级别的功能调用, ...
- nginx 常用的 URL 重写方法
转自:http://www.jbxue.com/article/4727.html Nginx中一些常用的URL 重写方法介绍,有需要的朋友可以参考下.url重写应该不陌生,不管是SEO URL 伪静 ...
- python27读书笔记0.2
# -*- coding:utf-8 -*- ##s.partition(d)##Searches string s for the first occurrence of some delimite ...
- opengl混合效果
效果如下图:
- Git常用命令汇总
1.初始化相关 git init 初始化仓库 git remove add origin url 添加仓库地址 git remove rm origin 删除仓库地址 git clone 克隆别人的分 ...
- 开发设计模式(一)Command模式
Command定义 将来自客户端的请求传入一个对象,无需了解这个请求激活的 动作或有关接受这个请求的处理细节. 这是一种两台机器之间通讯联系性质的模式,类似传统过程语 言的 CallBack功能. 优 ...
- Grails的redirect无法跳转时的一个可能原因
由于controller的命名一般首字母大写,如Login 此时如 class LoginController { def index = { redirect(action:Login, param ...