CodeForces 700A As Fast As Possible
要保证总时间最短,因为总时间计的是最后一个人到达的时间,也就是最后一个人要求尽快到达,也就是说我们要让最后一个人乘车时间尽量多。再仔细想想可以发现每个人的乘车时间和走路时间都是一样的。
因此,可以二分每个人的乘车时间$m$,然后进行验证,如果发现某一个人的乘车时间不到$m$,那么$m$不可取,上界缩小;如果$m$可取,那么上界增大。
#pragma comment(linker, "/STACK:1024000000,1024000000")
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<vector>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<iostream>
using namespace std;
typedef long long LL;
const double pi=acos(-1.0),eps=1e-;
void File()
{
freopen("D:\\in.txt","r",stdin);
freopen("D:\\out.txt","w",stdout);
}
template <class T>
inline void read(T &x)
{
char c = getchar(); x = ;while(!isdigit(c)) c = getchar();
while(isdigit(c)) { x = x * + c - ''; c = getchar(); }
} int n,L,v1,v2,k; bool check(double m)
{
double x=; int p=n;
while()
{
p=p-min(p,k); double t=(1.0*L-x)/v2;
if(t<m) return ; if(p==) break;
x=x+v1*m; double tmp=m*(v2-v1)/(v1+v2);
x=x+tmp*v1;
}
return ;
} int main()
{
scanf("%d%d%d%d%d",&n,&L,&v1,&v2,&k);
double left=,right=1.0*L/v2,ans=;
int T=;
while(T--)
{
double m=(left+right)/;
if(check(m)) left=m,ans=m+(1.0*L-m*v2)/v1;
else right=m;
}
printf("%.6lf\n",ans);
return ;
}
CodeForces 700A As Fast As Possible的更多相关文章
- Codeforces 700A As Fast As Possible(二分答案)
		
[题目链接] http://codeforces.com/problemset/problem/700/A [题目大意] 有一辆限载k人速度为v2的车,n个步行速度均为v1的人要通过一段长度为l的距离 ...
 - codeforces 700A As Fast As Possible 二分求和?我觉得直接解更好
		
分析:一辆车最多载k个人,车的速度肯定比人快,所以想要到达时间最短,那么每个人必须做一次公交车.那么把n个人分成p=(n+k-1)/k组.设最短时间为t,每人乘车时间为t1,则t1*v2+(t-t1) ...
 - codeforces 700a//As Fast As Possible// Codeforces Round #364(Div. 1)
		
题意:n个人要运动ll长,有个bus带其中几个人,问最短时间 最后所有人在同一时间到终点是用时最少的.由于搭bus相当于加速,每个人的加速时间应该一样.先计算bus走过的路程route.看第一个人被搭 ...
 - codeforces #364d As Fast As Possible
		
题意:一群学生,要到离这里为l的地方去.有一辆车,车只有k个座位.人和车的速度分别v1,v2,问你所有人到达的最小时间. 思路:数学题.最小时间就是要求所有同学同时到达.每个同学最多上一次车.那么显然 ...
 - Codeforces 866C Gotta Go Fast - 动态规划 - 概率与期望 - 二分答案
		
You're trying to set the record on your favorite video game. The game consists of N levels, which mu ...
 - [Codeforces 865C]Gotta Go Fast(期望dp+二分答案)
		
[Codeforces 865C]Gotta Go Fast(期望dp+二分答案) 题面 一个游戏一共有n个关卡,对于第i关,用a[i]时间通过的概率为p[i],用b[i]通过的时间为1-p[i],每 ...
 - Codeforces Round #622 (Div. 2) A. Fast Food Restaurant(全排列,DFS)
		
Codeforces Round #622 (Div. 2) A. Fast Food Restaurant 题意: 你是餐馆老板,虽然只会做三道菜,上菜时还有个怪癖:一位客人至少上一道菜,且一种菜最 ...
 - Codeforces Round  #364 (Div.2) D:As Fast As Possible(模拟+推公式)
		
题目链接:http://codeforces.com/contest/701/problem/D 题意: 给出n个学生和能载k个学生的车,速度分别为v1,v2,需要走一段旅程长为l,每个学生只能搭一次 ...
 - Codeforces Round #364 (Div. 2) D. As Fast As Possible
		
D. As Fast As Possible time limit per test 1 second memory limit per test 256 megabytes input stand ...
 
随机推荐
- vmare虚拟化解决方案
			
最近刚入职一家公司!主要是做vmare虚拟化的,虽然跟openstack不太沾边,但现在很多openstack都会兼容vmare程序,最终会如何我拭目以待,今天写这个也是做一个总结. 虚拟化.云计算. ...
 - USACO 4.1 Fence Loops(Floyd求最小环)
			
Fence Loops The fences that surround Farmer Brown's collection of pastures have gotten out of contro ...
 - Kattis - Biased Standings
			
Biased Standings Usually, results of competitions are based on the scores of participants. However, ...
 - PSR
			
目前包括以下几个规范: PSR-0(弃用) PSR-1 PSR-2 PSR-3 PSR-4 1.PSR-0 自动加载规范,此规范已被启用-本规范已于2014年10月21日被标记为弃用,目前新的替代规范 ...
 - CSS3 background-size:cover/contain
			
background-size的cover和contain指定背景图片的自适应方式,只能对整张图片进行缩放. cover是拉伸图片使之充满元素,元素肯定是被铺满的,但是图片有可能显示不全. conta ...
 - MyBatis学习-映射文件标签篇(select、resultMap)
			
MyBatis 真正的核心在映射文件中.比直接使用 JDBC 节省95%的代码.而且将 SQL 语句独立在 Java 代码之外,可以进行更为细致的 SQL 优化. 一. 映射文件的顶级元素 selec ...
 - JavaScript忍者秘籍——原型
			
概要:本篇博客主要介绍JavaScript的原型 1.对象实例化 - 初始化的优先级 初始化操作的优先级如下: ● 通过原型给对象实例添加的属性 ● 在构造器函数内给对象实例添加的属性 在构造器内的绑 ...
 - 关于mac地址的一点感想
			
因为怕mac地址冲突导致环路影响,所以修改了本地设备的mac地址.地址修改为 77:77:77:00:22:11, 结果导致 wlan0 下发不下来. 查看配置选项/etc/config/wirele ...
 - HUD 1171 Big Event in HDU(01背包)
			
Big Event in HDU Problem Description Nowadays, we all know that Computer College is the biggest depa ...
 - Chapter 19_0 位操作库
			
位操作库是Lua5.2版本里添加的库,所有函数放在bit32 table里.(bit32只能针对32位整数运算) 在Lua5.3版本里,bit32库被废弃掉.不过可以使用一个外部兼容库,但是最好直接用 ...