hdu4717The Moving Points(三分)
需要特判一下n=1的时候
精度调太低会超时
#include <iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<stdlib.h>
#include<vector>
#include<cmath>
#include<queue>
#include<set>
using namespace std;
#define N 310
#define LL long long
#define INF 1e8
const double eps = 1e-;
const double pi = acos(-1.0);
const double inf = ~0u>>;
struct point
{
double x,y;
double vx,vy;
}p[N],pp[N];
int n;
double dis(point a,point b)
{
return sqrt((a.x-b.x)*(a.x-b.x)+(a.y-b.y)*(a.y-b.y));
}
double calc(double tt)
{
int i,j;
for(i = ; i <= n; i++)
{
pp[i].x=p[i].x+tt*p[i].vx;
pp[i].y=p[i].y+tt*p[i].vy;
}
double ans = 0.0;
for(i = ; i <= n; i++)
{
for(j = ; j <= n ;j++)
ans = max(ans,dis(pp[i],pp[j]));
}
return ans;
}
void solve(int k)
{
double M,RM;
double L = 0.0;
double R = INF;
while (L + eps < R)
{
M = (L + R) / ;
RM = (M + R) / ;
double s1 = calc(M);
double s2 = calc(RM);
if ( s1 < s2 ) R = RM;
else L = M;
}
printf("Case #%d: ",k);
printf("%.2f %.2f\n",R,calc(R));
}
int main()
{
int t,i;
int kk = ;
cin>>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);
if(n==)
{
printf("0.00 0.00\n");
continue;
}
solve(++kk);
}
return ;
}
hdu4717The Moving Points(三分)的更多相关文章
- HDU 4717 The Moving Points(三分)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4717 题意:给出n个点的坐标和运动速度(包括方向).求一个时刻t使得该时刻时任意两点距离最大值最小. ...
- 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 ...
- 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 ...
- The Moving Points hdu4717
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的題目更容易 ...
- hdu 4717 The Moving Points(第一个三分题)
http://acm.hdu.edu.cn/showproblem.php?pid=4717 [题意]: 给N个点,给出N个点的方向和移动速度,求每个时刻N个点中任意两点的最大值中的最小值,以及取最小 ...
随机推荐
- Function对象属性和方法
/* var pattern = /^[\w]+\.(zip|rar|gz)$/; //|选择符必须用分组符号包含起来 var str = '123.7z'; alert(pattern.test(s ...
- vs 常见问题汇总
vs添加对dll的引用 我们在使用vs进行开发调试的时候经常会遇到一个问题,就是当我们的主工程引用到其他工程更新的dll(我们经常采用copy到工程目录的方法).亦或者当我们的多个工程引用到同一个dl ...
- intellij idea 10.5介绍
IDEA 全称 IntelliJ IDEA,是java语言开发的集成环境,IntelliJ在业界被公认为最好的java开发工具之一,尤其在智能代码助手.代码自动提示.重构.J2EE支持.Ant.JUn ...
- Balance
Balance Time Limit: 1000MS Memory Limit: 30000K Total Submissions: 11947 Accepted: 7464 Description ...
- 【转】写一个标准宏MIN,这个宏输入两个参数并返回较小的那个。另外当写下least=MIN(*p++,b)时会发生什么
解答:#define MIN(A,B) ((A) <= (B) ? (A) : (B)) MIN(*p++, b)会产生宏副作用 剖析:这个面试题主要考察宏定义可以实现函数的功能.但是它终归不是 ...
- 基本Socket通信流程
服务器常用模型 1.初始化Socket (用于监听) 1)初始化 SOCKET s ; s = Socket ( ... ) 2)绑定 bind(s, ...); 3)监听 listen(s, .. ...
- 实现的时钟(time)
<!doctype html><html lang="en"><head> <script type="text/javascr ...
- MySQL PLSQL Demo - 005.IF THEN ELSEIF THEN ELSE END IF
drop procedure if exists p_hello_world; create procedure p_hello_world(in v_id int) begin ) then sel ...
- 改变CSS样式
改变CSS样式 1.改变HTML元素样式的语法 //改变HTML样式的语法 document.getElementById(id).style.property = new style 例子: < ...
- dictionaryWithObjectsAndKeys
NSDictionary dictionaryWithObjectsAndKeys NSDictionary *parmDic = [NSDictionary dictionaryWithObj ...