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 ...
随机推荐
- AIX加入�能够telnet远程连接账号方法
AIX 中加入�账号能够使用命令mkuser 和 SMIT 两种方式,这里介绍SMIT方式 1.使用root 账号登录AIX 2.输入 smitty user 3.选择Add a User 4.输入& ...
- Android图片加载框架最全解析(六),探究Glide的自定义模块功能
不知不觉中,我们的Glide系列教程已经到了第六篇了,距离第一篇Glide的基本用法发布已经过去了半年的时间.在这半年中,我们通过用法讲解和源码分析配合学习的方式,将Glide的方方面面都研究了个遍, ...
- 如何利用启明星Portal门户系统的Page模块构建文档库
利用启明星门户系统的Page模块构架可以搭建企业内部的文档管理系统. (一)应用背景 企业内部通常都会使用共享网盘的方式来存放不同部门之间的文档,例如管理员在服务器上对人事部门增加人事部文档文件夹. ...
- RuntimeError: Working outside of application context.
flask执行错误: 问题:RuntimeError: Working outside of application context. 方法: from flask import Flask, cur ...
- Grunt常见问题
1.nodeJs 环境安装?进入官网:http://www.nodejs.org/ 根据操作系统,下载相应的安装包,直接安装即可. 2.npm 安装?a) 如果系统没有安装过Git,可以直接到http ...
- C#读写txt文件的两种方法介绍[转]
C#读写txt文件的两种方法介绍 1.添加命名空间 System.IO; System.Text; 2.文件的读取 (1).使用FileStream类进行文件的读取,并将它转换成char数组,然后输出 ...
- jquery选择器的实现流程简析及提高性能建议!
当我们洋洋得意的使用jquery强大的选择器功能时有没有在意过jquery的选择性能问题呢,其实要想高效的使用jquery选择器,了解其实现流程是很有必要的,那么这篇文章我就简单的讲讲其实现流程,相信 ...
- ECMAScript5之Object学习笔记(三)
第三部分继续... Object.getOwnPropertyDescriptor(obj, prop) 获取一个对象的属性描述符 根据"Own"这个词我们可以猜到,prop只能是 ...
- 【Nodejs】nimble或async并不能保证程序串行执行,回调是回避不了的坑
先看一段例程: //------------------------------- // 用于创建目录 //------------------------------- function creat ...
- 如何使用FLASHGOT下载网页FLASH
1 注意火狐的广告屏蔽插件可能将一些有用的东西屏蔽掉,从而无法得到广告FLASH, 2 随后即可在桌面上找到所需文件 你也可以按住A/T并单击FLASH文件(不论鼠标是否被替换为其他图形)迅雷会自动探 ...