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): 2122 Accepted Submission(s): 884
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).
#pragma GCC diagnostic error "-std=c++11"
//#include <bits/stdc++.h>
#define _ ios_base::sync_with_stdio(0);cin.tie(0);
#include<iostream>
#include<algorithm>
#include<cstdio>
using namespace std; const double eps = 1e-;
const int N= + ;
struct point{
double x, y, vx, vy;
void read(){ cin >> x >> y >> vx >> vy; }
}p[N];
int n; double dist_points(point p1, point p2, double t){
double x = (p1.x + t * p1.vx) - (p2.x + t * p2.vx);
double y = (p1.y + t * p1.vy) - (p2.y + t * p2.vy);
return sqrt(x * x + y * y);
} double cal(double x){
double Max = ;
for(int i = ; i < n; i++)
for(int j = i + ; j < n; j++)
Max = max(Max, dist_points(p[i], p[j], x));
return Max;
} double ternary_search(double L, double R){
if(L > R) swap(L, R);
while(R - L > eps){
double mid1, mid2;
mid1 = (L + R) / ;
mid2 = (mid1 + R) / ;
if(cal(mid1) <= cal(mid2)) R = mid2;
else L = mid1;
}
return (L + R) / ;
}
int main(){ _
int T, Cas = ;
cin >> T;
while(T --){
cin >> n;
for(int i = ; i < n; i++) p[i].read();
double x = ternary_search(, 1e8);
printf("Case #%d: %.2f %.2f\n", ++Cas, x, cal(x));
}
}
HDU-4717 The Moving Points(凸函数求极值)的更多相关文章
- HDU 4717 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(三分)
题目链接: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(三分法)(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& ...
- hdu 4717: The Moving Points 【三分】
题目链接 第一次写三分 三分的基本模板 int SanFen(int l,int r) //找凸点 { ) { //mid为中点,midmid为四等分点 ; ; if( f(mid) > f(m ...
- HDOJ 4717 The Moving Points
The Moving Points Time Limit: 6000/3000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others ...
随机推荐
- Codeforces 798D Mike and distribution (构造)
题目链接 http://codeforces.com/contest/798/problem/D 题解 前几天的模拟赛,居然出这种智商题..被打爆了QAQ 这个的话,考虑只有一个序列怎么做,把所有的排 ...
- [CF1172E]Nauuo and ODT:Link-Cut Tree
分析 lxl大毒瘤. 感谢Ouuan等CNOIER提供了这么好的比赛. 这里只是把官方题解复述一遍,可以直接去看官方题解:点我. 考虑将问题转化为对于每个颜色,求出没有经过这个颜色的节点的路径有多少条 ...
- win7,win10 系统上搭建testlink1.9.18环境实操步骤
Windows7,10系统上安装TestLink1.9.18(基于xampp) 写于:2018.11.28 二次排版微调:2019.01.01 如遇本文资料缺失,可点击百度网盘查看原始资料. 链接:h ...
- idea 下运行安卓项目
修改 gralde 路径修改安卓sdk路径进入project structure 设置 Project settings / Project /project SDK 选择 Android API 2 ...
- spring eclipse xml自动提示
window -> preferences -> XML -> XML Catalog -> 在User Specified Entries新增加一个catalog
- 2018-2019-2 网络对抗技术 20165232 Exp 9 Web安全基础
2018-2019-2 网络对抗技术 20165232 Exp 9 Web安全基础 实验任务 本实践的目标理解常用网络攻击技术的基本原理,做不少于7个题目,共3.5分.包括(SQL,XSS,CSRF) ...
- Python学习笔记:list的各种操作
向一个列表中添加单个元素: my_list = []my_list.append('我爱你') 移除列表中的某个元素: my_list.pop(0) # 0是需要移除元素在列表中的index 或者是移 ...
- The control collection cannot be modified during DataBind, Init, Load, PreRender or Unload phases.
https://stackoverflow.com/questions/5508666/dynamically-add-html-to-asp-net-page https://stackoverfl ...
- leetcode-easy-others-268 Missing Number
mycode 80.25% class Solution(object): def missingNumber(self, nums): """ :type nums ...
- Spring配置多个数据源,并实现数据源的动态切换转载)
1.首先在config.properties文件中配置两个数据库连接的基本数据.这个省略了 2.在spring配置文件中配置这两个数据源: 数据源1 <!-- initialSize初始化时建立 ...