codeforces 782B The Meeting Place Cannot Be Changed+hdu 4355+hdu 2438 (三分)
The main road in Bytecity is a straight line from south to north. Conveniently, there are coordinates measured in meters from the southernmost building in north direction.
At some points on the road there are n friends, and i-th of them is standing at the point xi meters and can move with any speed no greater than vi meters per second in any of the two directions along the road: south or north.
You are to compute the minimum time needed to gather all the n friends at some point on the road. Note that the point they meet at doesn't need to have integer coordinate.
The first line contains single integer n (2 ≤ n ≤ 60 000) — the number of friends.
The second line contains n integers x1, x2, ..., xn (1 ≤ xi ≤ 109) — the current coordinates of the friends, in meters.
The third line contains n integers v1, v2, ..., vn (1 ≤ vi ≤ 109) — the maximum speeds of the friends, in meters per second.
Print the minimum time (in seconds) needed for all the n friends to meet at some point on the road.
Your answer will be considered correct, if its absolute or relative error isn't greater than 10 - 6. Formally, let your answer be a, while jury's answer be b. Your answer will be considered correct if
holds.
3
7 1 3
1 2 1
2.000000000000
4
5 10 3 2
2 3 2 4
1.400000000000
In the first sample, all friends can gather at the point 5 within 2 seconds. In order to achieve this, the first friend should go south all the time at his maximum speed, while the second and the third friends should go north at their maximum speeds.
题意:x轴上有n个人 坐标为xi 最大行驶速度为vi 让这n个人走到相同一点的最短时间上多少
三分坐标 每次看到达这个坐标的最大时间 相互比较
#include<iostream>
#include<cstdio>
#include<cmath>
#include<map>
#include<cstdlib>
#include<vector>
#include<set>
#include<queue>
#include<cstring>
#include<string.h>
#include<algorithm>
#define INF 0x3f3f3f3f
typedef long long ll;
typedef unsigned long long LL;
using namespace std;
const double eps=0.0000001;
const int N=+;
double a[N],b[N];
int n;
double fun(double x){
double ans=;
for(int i=;i<n;i++)ans=max(ans,fabs(x-a[i])/b[i]);
return ans;
}
int main(){
while(scanf("%d",&n)!=EOF){
double maxx=-1.0*INF;
double minn=1.0*INF;
for(int i=;i<n;i++){
scanf("%lf",&a[i]);
maxx=max(maxx,a[i]);
minn=min(minn,a[i]);
}
for(int i=;i<n;i++)scanf("%lf",&b[i]);
double high=maxx;
double low=minn;
while(low+eps<high){
double mid=(high+low)/2.0;
double midd=(mid+high)/2.0;
if(fun(mid)<fun(midd))high=midd;
else
low=mid;
}
printf("%.12f\n",fun(low));
}
}
hdu 4355
Party All the Time
Time Limit: 6000/2000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 5384 Accepted Submission(s): 1679
the Dark forest, there is a Fairy kingdom where all the spirits will go
together and Celebrate the harvest every year. But there is one thing
you may not know that they hate walking so much that they would prefer
to stay at home if they need to walk a long way.According to our
observation,a spirit weighing W will increase its unhappyness for S3*W units if it walks a distance of S kilometers.
Now
give you every spirit's weight and location,find the best place to
celebrate the harvest which make the sum of unhappyness of every spirit
the least.
first line of the input is the number T(T<=20), which is the number
of cases followed. The first line of each case consists of one integer
N(1<=N<=50000), indicating the number of spirits. Then comes N
lines in the order that x[i]<=x[i+1] for all i(1<=i<N). The i-th line contains two real number : Xi,Wi, representing the location and the weight of the i-th spirit. ( |xi|<=106, 0<wi<15 )
each test case, please output a line which is "Case #X: Y", X means the
number of the test case and Y means the minimum sum of unhappyness
which is rounded to the nearest integer.
#include<iostream>
#include<cstdio>
#include<cmath>
#include<map>
#include<cstdlib>
#include<vector>
#include<set>
#include<queue>
#include<cstring>
#include<string.h>
#include<algorithm>
#define INF 0x3f3f3f3f
typedef long long ll;
typedef unsigned long long LL;
using namespace std;
const double eps=0.00000001;
const int N=+;
int n;
struct node{
double x;
double w;
}a[N];
double fun(double x){
double ans=0.0;
for(int i=;i<n;i++){
double t=fabs(a[i].x-x);
ans=ans+t*t*t*a[i].w;
}
return ans;
}
int main(){
//cout<<eps<<endl;
int t;
scanf("%d",&t);
for(int k=;k<=t;k++){
scanf("%d",&n);
double minn=1.0*INF;
double maxx=-1.0*INF;
for(int i=;i<n;i++){
scanf("%lf%lf",&a[i].x,&a[i].w);
maxx=max(maxx,a[i].x);
minn=min(minn,a[i].x);
}
double low=minn;
double high=maxx;
double ans=low;
while(low+eps<high){
double mid=(low+high)/2.0;
double midd=(mid+high)/2.0;
// cout<<fun(mid)<<" "<<fun(midd)<<endl;
if(fun(mid)<fun(midd)){
high=midd;
}
else{
low=mid;
ans=low;
} }
printf("Case #%d: %.0f\n",k,fun(ans));
}
}
hdu 2438
Turn the corner
Time Limit: 3000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 3181 Accepted Submission(s): 1289
One
day he comes to a vertical corner. The street he is currently in has a
width x, the street he wants to turn to has a width y. The car has a
length l and a width d.
Can Mr. West go across the corner?

Proceed to the end of file.
求f(a)=l*cos(a)-(x-w/cos(a))/tan(a);
#include<iostream>
#include<cstdio>
#include<cmath>
#include<map>
#include<cstdlib>
#include<vector>
#include<set>
#include<queue>
#include<cstring>
#include<string.h>
#include<algorithm>
#define INF 0x3f3f3f3f
typedef long long ll;
typedef unsigned long long LL;
using namespace std;
const double PI=acos(-1.0);
const double eps=0.00000001;
double x,y,l,w;
double fun(double a){
double ans=l*cos(a)-(x-w/cos(a))/tan(a);
return ans;
}
int main(){
while(scanf("%lf%lf%lf%lf",&x,&y,&l,&w)!=EOF){
double low=0.0;
double high=PI/2.0;
if(x<w||y<w)
{
cout<<"no"<<endl;
continue;
}
while(low+eps<high){
double mid=(low+high)/2.0;
double midd=(mid+high)/2.0;
if(fun(mid)<=fun(midd)){
low=mid;
}
else
high=midd;
}
if(fun(low)<=y)cout<<"yes"<<endl;
else
cout<<"no"<<endl;
}
}
codeforces 782B The Meeting Place Cannot Be Changed+hdu 4355+hdu 2438 (三分)的更多相关文章
- codeforces 782B The Meeting Place Cannot Be Changed (三分)
The Meeting Place Cannot Be Changed Problem Description The main road in Bytecity is a straight line ...
- Codeforces 782B The Meeting Place Cannot Be Changed(二分答案)
题目链接 The Meeting Place Cannot Be Changed 二分答案即可. check的时候先算出每个点可到达的范围的区间,然后求并集.判断一下是否满足l <= r就好了. ...
- codeforces 782B - The Meeting Place Cannot Be Changed
time limit per test 5 seconds memory limit per test 256 megabytes input standard input output standa ...
- CodeForces 782B The Meeting Place Cannot Be Changed (二分)
题意:题意:给出n个人的在x轴的位置和最大速度,求n个人相遇的最短时间. 析:二分时间,然后求并集,注意精度,不然会超时. 代码如下: #pragma comment(linker, "/S ...
- CodeForces - 782B The Meeting Place Cannot Be Changed(精度二分)
题意:在一维坐标轴上,给定n个点的坐标以及他们的最大移动速度,问他们能聚到某一点处的最短时间. 分析: 1.二分枚举最短时间即可. 2.通过检查当前时间下,各点的最大移动范围之间是否有交集,不断缩小搜 ...
- 782B. The Meeting Place Cannot Be Changed 二分 水
Link 题意:给出$n$个坐标$x_i$,$n$个速度$v_i$问使他们相遇的最短时间是多少. 思路:首先可肯定最终相遇位置必定在区间$[0,max(x_i)]$中,二分最终位置,判断左右部分各自所 ...
- 782B The Meeting Place Cannot Be Changed(二分)
链接:http://codeforces.com/problemset/problem/782/B 题意: N个点,需要找到一个点使得每个点到这个点耗时最小,每个点都同时开始,且都拥有自己的速度 题解 ...
- Codeforces Round #403 (Div. 2, based on Technocup 2017 Finals) B. The Meeting Place Cannot Be Changed
地址:http://codeforces.com/contest/782/problem/B 题目: B. The Meeting Place Cannot Be Changed time limit ...
- AC日记——The Meeting Place Cannot Be Changed codeforces 780b
780B - The Meeting Place Cannot Be Changed 思路: 二分答案: 代码: #include <cstdio> #include <cstrin ...
随机推荐
- Oracle基础理论笔记(一):模式概念
---oracle 10g 1.在oracle数据库中,数据对象是以模式为单位进行组织和管理的.模式是指一系列的逻辑数据结构或对象的集合. 2.模式与用户名相对应,一个模式只能对应一个用户,并且该模式 ...
- 【译】x86程序员手册04 - 2.2数据类型
2.2 Data Types 数据类型 Bytes, words, and doublewords are the fundamental data types (refer to Figure 2- ...
- JQuery文档加载完成执行js的几种方法
js中文档加载完毕.一般在body加一个onload事件或者window.onload = function () {} jQuery中有好多写法,平时也不注意,别人一问,还真觉得头大. 下面是我整理 ...
- C# 扩展类的内置方法
public class A//先定义A类 { } public static class Extension//必须先声明一个静态类,类名随意 { public static int ToInt32 ...
- day09-文件的操作
目录 文件的基本操作 文件 什么是文件 如何使用文件 打开&关闭文件 打开&关闭文件 del f和f.close()的区别 文件路径 打开模式(不写默认是r) 编码格式 补充(open ...
- 从 UI 交互角度说语音识别产品
语言是人类进化的主要特征,而人工智能拥有了说话的能力也是科技进步的一个特征.在很多科幻的电影里面,我们可以看到人工智能的身影.在电影 her 里面见到的人工智能,真的让人叹为观止,他可以随意的和你聊天 ...
- Vova and Trophies CodeForces - 1082B(思维题)
Vova has won nn trophies in different competitions. Each trophy is either golden or silver. The trop ...
- ES6 基础学习
ECMAScript 6 标准入门 一.let和const let命令 let命令,用来声明变量.它的用法类似于var,但是所声明的变量,只在let命令所在的代码块内有效:是块级作用域,且let不允许 ...
- Python2 下Ubuntu linux Mac 安装 PyV8
在pip install PyV8(注意区分大小写)时,出现了如下报错 command 'x86_64-linux-gnu-gcc' failed with exit status 1 解决方案: 百 ...
- webstorm汉化后乱码现象解决
本人之前使用的编辑器是sublime,今天换成webstrom,汉化时出现乱码现象,一开始我以为是没安装完整所以重装了好几遍,后来百度后才知道是webstrom字体类型的问题,具体解决方法如图,点击最 ...