HDU 4717 The Moving Points (三分)
The Moving Points
Time Limit: 6000/3000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 72 Accepted Submission(s): 18
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
/* ***********************************************
Author :kuangbin
Created Time :2013-9-11 13:51:21
File Name :2013-9-11\1002.cpp
************************************************ */ #include <stdio.h>
#include <string.h>
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <string>
#include <math.h>
#include <stdlib.h>
#include <time.h>
using namespace std;
const double eps = 1e-;
const int MAXN = ;
int n;
double x[MAXN];
double y[MAXN];
double vx[MAXN];
double vy[MAXN]; double calc(double t)
{
double ret = ;
for(int i = ;i < n;i++)
for(int j = i+;j < n;j++)
{
double x1 = x[i] + vx[i]*t;
double y1 = y[i] + vy[i]*t;
double x2 = x[j] + vx[j]*t;
double y2 = y[j] + vy[j]*t;
ret = max(ret,sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2)));
}
return ret;
}
double solve()
{
double l = , r = 1e10;
while(r-l >= eps)
{
double mid = (l+r)/;
double midmid = (mid + r)/;
double tmp1 = calc(mid);
double tmp2 = calc(midmid);
if(tmp2 > tmp1)r = midmid-eps;
else l = mid + eps;
}
return l;
} int main()
{
//freopen("in.txt","r",stdin);
//freopen("out.txt","w",stdout);
int T;
scanf("%d",&T);
int iCase = ;
while(T--)
{
iCase ++;
scanf("%d",&n);
for(int i = ;i < n;i++)
scanf("%lf%lf%lf%lf",&x[i],&y[i],&vx[i],&vy[i]);
double t = solve();
printf("Case #%d: %.2lf %.2lf\n",iCase,t,calc(t));
}
return ;
}
HDU 4717 The Moving Points (三分)的更多相关文章
- HDU 4717 The Moving Points(三分)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4717 题意:给出n个点的坐标和运动速度(包括方向).求一个时刻t使得该时刻时任意两点距离最大值最小. ...
- hdu 4717 The Moving Points(第一个三分题)
http://acm.hdu.edu.cn/showproblem.php?pid=4717 [题意]: 给N个点,给出N个点的方向和移动速度,求每个时刻N个点中任意两点的最大值中的最小值,以及取最小 ...
- hdu 4717 The Moving Points(三分+计算几何)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4717 说明下为啥满足三分: 设y=f(x) (x>0)表示任意两个点的距离随时间x的增长,距离y ...
- hdu 4717 The Moving Points(三分)
http://acm.hdu.edu.cn/showproblem.php?pid=4717 大致题意:给出每一个点的坐标以及每一个点移动的速度和方向. 问在那一时刻点集中最远的距离在全部时刻的最远距 ...
- hdu 4717: The Moving Points 【三分】
题目链接 第一次写三分 三分的基本模板 int SanFen(int l,int r) //找凸点 { ) { //mid为中点,midmid为四等分点 ; ; if( f(mid) > f(m ...
- 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 ...
- HDU 4717 The Moving Points (三分法)
题意:给n个点的坐标的移动方向及速度,问在之后的时间的所有点的最大距离的最小值是多少. 思路:三分.两点距离是下凹函数,它们的max也是下凹函数.可以三分. #include<iostream& ...
- HDOJ 4717 The Moving Points
The Moving Points Time Limit: 6000/3000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others ...
- hdu4717The Moving Points(三分)
链接 需要特判一下n=1的时候 精度调太低会超时 #include <iostream> #include<cstdio> #include<cstring> #i ...
随机推荐
- java基础67 JavaScript通过关系找节点、添加附件(网页知识)
1.通过关系找节点(父子关系,兄弟关系) 1.1.常用方法 parentNode:获取当前元素的父节点. childNodes:获取当前元素的所有下一级子元素 firstChild:获取当 ...
- [android]Intent跳转新的Activity可以传递数据过去
两种方式: 一,直接通过Bundle对象来传递: 如果我们想要给“收件人”Activity说点什么的话,那么可以通过下面这封“E-mail”来将我们的消息传递出去 Intent intent=new ...
- Codeforces 225C Barcode(矩阵上DP)
题目链接:http://codeforces.com/contest/225/problem/C 题目大意: 给出一个矩阵,只有两种字符'.'和'#',问最少修改多少个点才能让每一列的字符一致,且字符 ...
- const分别在C和C++语言里的含义和实现机制
const的含义 简单地说:const在c语言中表示只读的变量,而在c++语言中表示常量. C语言 const是constant的缩写,是恒定不变的意思,也翻译为常量,但是很多人都认为被 ...
- 基于centos6构建私有gitbook平台
前言: 开源gitbook工具可以让你方便有效的管理自己的文章笔记.发布产品文档等.这里为了学习,基于centos系统构建一个私有的gitbook项目.与公有云gitbook平台相比,这里是简单的展示 ...
- Python下opencv使用笔记(图像的平滑与滤波)
对于图形的平滑与滤波,但从滤波角度来讲,一般主要的目的都是为了实现对图像噪声的消除,增强图像的效果. 对于2D图像可以进行低通或者高通滤波操作 低通滤波(LPF):有利于去噪,模糊图像 高通滤波(HP ...
- Bootstrap进阶六:动态样式语言LESS简介
LESS 将 CSS 赋予了动态语言的特性,如 变量, 继承, 运算, 函数. LESS 既可以在 客户端 上运行 (支持IE 6+, Webkit, Firefox),也可以借助Node.js或者R ...
- 码云Android项目构建注意事项(转载)
1.ant项目 build.xml必须位于项目根目录. 2.maven项目 pom.xml必须位于项目根目录. 3.gradle项目 由于gradle的配置灵活,我们做了一些规范,并且增加了一下机制来 ...
- jump game(贪心算法)
Given an array of non-negative integers, you are initially positioned at the first index of the arra ...
- 设置 cookie过期时间
cookie.setMaxAge(0);//不记录cookie cookie.setMaxAge(-1);//会话级cookie,关闭浏览器失效 cookie.setMaxAge(60*60);//过 ...