HDUOJ---The Moving Points
The Moving Points
Time Limit: 6000/3000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 612 Accepted Submission(s): 250
#include<iostream>
#include<vector>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<cmath>
#define MAX 1e9
#define exp 1e-6
using namespace std;
//设置结构体
typedef struct
{
int x,y;
int px,py;
}point; //计算任意时间两点的距离
double das(point a,point b,double t )
{
return sqrt(pow(((a.x+a.px*t)-(b.x+b.px*t)),)+pow(((a.y+a.py*t)-(b.y+b.py*t)),));
}
//判断两个数最大值....
double max( double a,double b)
{
return a>b?a:b;
}
point po[];
int main()
{
int n,i,j,cnt=,t;
double ll,rr,ml,mr,ans1,ans2;
scanf("%d",&t);
while(t--)
{
scanf("%d",&n);
for( i= ; i<=n ; i++ )
{
scanf("%d%d%d%d",&po[i].x,&po[i].y,&po[i].px,&po[i].py);
//cin>>po[i].x>>po[i].y>>po[i].px>>po[i].py;
}
//没有其他的办法,除了遍历之外
ll=0.0,rr=MAX;
while(rr-ll>exp)
{
ans1=ans2=0.0;
//ml=(ll+rr)/2.0; //慢很多
//mr=(ml+rr)/2.0;
ml=(ll*+rr)/3.0; // r/3.0 较快
mr=(ll+rr*)/3.0; // 2*r/3.0
for( i= ; i<n ; i++ )
{
for( j=i+ ; j<=n ;j++ )
{
ans1=max(ans1,das(po[i],po[j],ml)); //对左边
ans2=max(ans2,das(po[i],po[j],mr)); //对右边
}
}
if( ans1<ans2 )
rr=mr;
else
ll=ml;
}
//得到时间ll or rr 都可以
ans1=0.0;
for(i= ; i<n ; i++ )
{
for(j=+i ; j<=n ;j++)
{
ans1=max(ans1,das(po[i],po[j],ll)); //对左边ll/rr
}
}
printf("Case #%d: %.2lf %.2lf\n",cnt++,ll,ans1);
}
return ;
}
HDUOJ---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 ...
- 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
Problem Description There are N points in total. Every point moves in certain direction and certain ...
- 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 ...
随机推荐
- hue解决timed out(code THRIFTSOCKET):None
报错栈: Traceback (most recent call last): File , in decorator return func(*args, **kwargs) File , in e ...
- strchr实现
char* strchr(char*s,charc) { while(*s!='\0'&&*s!=c) { ++s; } return*s==c?s:NULL; } // strchr ...
- version control system:git/hg/subversion/cvs/clearcase/vss。software configruation management。代码集成CI:Cruisecontrol/hudson/buildbot
version control system: git/hg/subversion/cvs/clearcase/vss software configruation management: daily ...
- 【POJ】【2068】Art Gallery
计算几何/半平面交 裸的半平面交,关于半平面交的入门请看神犇博客:http://blog.csdn.net/accry/article/details/6070621 然而代码我是抄的proverbs ...
- TreeMap源代码深入剖析
第1部分 TreeMap介绍 A Red-Black tree based NavigableMap implementation. The map is sorted according to th ...
- 第一章 Java工具类目录
在这一系列博客中,主要是记录在实际开发中会常用的一些Java工具类,方便后续开发中使用. 以下的目录会随着后边具体工具类的添加而改变. 浮点数精确计算 第二章 Java浮点数精确计算 crc32将任意 ...
- 简单JavaScript语句实现搜索关键字高亮功能
高亮功能主要是指对页面中指定区域的指定文字进行高亮显示,也就是背景着色.一般在搜索结果页面会经常用到这个功能. 下面就为大家提供一种解决方案,用javascript实现. 首先在<head> ...
- php防止sql注入漏洞代码 && 几种常见攻击的正则表达式
注入漏洞代码和分析 ...
- 创建一个pre标签展开折叠的UI组件(原创)
这些天练习UI组件的编写,顺便模仿一个h5版本的pre标签收缩展开的效果组件: 兼容ie8.9,谷歌,火狐: 图片效果如下: demo.html代码: <!DOCTYPE html> &l ...
- Web前端开发资源集锦
前端开发已经成为当前炙手可热的技术之一.本周我们除了给大家带技术相关资讯,还有一些技术人员常用的网站.希望大家不要错过我们本周的内容.原文来自:极客标签 为神马说写程序是很艰难的 程序员 做一名优秀程 ...