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 ...
随机推荐
- Linux 获取网关地址
route命令的用法:操作或者显示IP路由表route:DESCRIPTION Route manipulates the kernel's IP routing tables. Its primar ...
- HDU 1068 Girls and Boys(最大独立集)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1068 题目大意:有n个人,一些人认识另外一些人,选取一个集合,使得集合里的每个人都互相不认识,求该集合 ...
- 关于int *a; int &a;a; int &a; *a; int * &a
int i; int*a =&i;//这里a是一个指针,它指向变量i int&b = i;//这里b是一个引用,它是变量i的引用,引用是什么?它的本质是什么?下面会具体讲述 int*& ...
- javaweb作业一
作业:Http全称叫什么?有什么特点?端口号是多少?超文本传输协议:(1)遵循请求/响应模型(2)http协议是一种无状态协议,请求/响应完成后,连接会断开.这时,服务器无法知道当前访问的用户是否是老 ...
- Jmeter的接口测试简介
一.安装Jmeter Jmeter官方首页:http://jmeter.apache. ...
- mysql千万级表关联优化
MYSQL一次千万级连表查询优化(一) 概述: 交代一下背景,这算是一次项目经验吧,属于公司一个已上线平台的功能,这算是离职人员挖下的坑,随着数据越来越多,原本的SQL查询变得越来越慢,用户体验特别差 ...
- linux 101 hacks 5PS1
PS1——默认提示符 看完这一章,我心里若干个卧槽.. 如下所示, 可以通过修改 Linux 下的默认提示符,使其更加实用.在下面的例子中,默认的 PS1的值是“ \s-\v\$”,显示出了 shel ...
- 面试题46:求1+2+ …… +n
题目:求1+2+…+n,要求不能使用乘除法.for.while.if.else.switch.case等关键字以及条件判断语句(A?B:C). 通常求1+2+…+n除了用公式n(n+1)/2之外,无外 ...
- slf4j logback pom
pom: <properties> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding&g ...
- 问题:SpringBoot访问不到Controller
SpringBoot正常启动,其它配置都正常,以下是控制台打印: 解决方法: 将controller与application配置文件同层,是访问时无法扫描到相应的controller,故无法映射到相应 ...