要保证总时间最短,因为总时间计的是最后一个人到达的时间,也就是最后一个人要求尽快到达,也就是说我们要让最后一个人乘车时间尽量多。再仔细想想可以发现每个人的乘车时间和走路时间都是一样的。

因此,可以二分每个人的乘车时间$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的更多相关文章

  1. Codeforces 700A As Fast As Possible(二分答案)

    [题目链接] http://codeforces.com/problemset/problem/700/A [题目大意] 有一辆限载k人速度为v2的车,n个步行速度均为v1的人要通过一段长度为l的距离 ...

  2. codeforces 700A As Fast As Possible 二分求和?我觉得直接解更好

    分析:一辆车最多载k个人,车的速度肯定比人快,所以想要到达时间最短,那么每个人必须做一次公交车.那么把n个人分成p=(n+k-1)/k组.设最短时间为t,每人乘车时间为t1,则t1*v2+(t-t1) ...

  3. codeforces 700a//As Fast As Possible// Codeforces Round #364(Div. 1)

    题意:n个人要运动ll长,有个bus带其中几个人,问最短时间 最后所有人在同一时间到终点是用时最少的.由于搭bus相当于加速,每个人的加速时间应该一样.先计算bus走过的路程route.看第一个人被搭 ...

  4. codeforces #364d As Fast As Possible

    题意:一群学生,要到离这里为l的地方去.有一辆车,车只有k个座位.人和车的速度分别v1,v2,问你所有人到达的最小时间. 思路:数学题.最小时间就是要求所有同学同时到达.每个同学最多上一次车.那么显然 ...

  5. 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 ...

  6. [Codeforces 865C]Gotta Go Fast(期望dp+二分答案)

    [Codeforces 865C]Gotta Go Fast(期望dp+二分答案) 题面 一个游戏一共有n个关卡,对于第i关,用a[i]时间通过的概率为p[i],用b[i]通过的时间为1-p[i],每 ...

  7. Codeforces Round #622 (Div. 2) A. Fast Food Restaurant(全排列,DFS)

    Codeforces Round #622 (Div. 2) A. Fast Food Restaurant 题意: 你是餐馆老板,虽然只会做三道菜,上菜时还有个怪癖:一位客人至少上一道菜,且一种菜最 ...

  8. Codeforces Round #364 (Div.2) D:As Fast As Possible(模拟+推公式)

    题目链接:http://codeforces.com/contest/701/problem/D 题意: 给出n个学生和能载k个学生的车,速度分别为v1,v2,需要走一段旅程长为l,每个学生只能搭一次 ...

  9. 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 ...

随机推荐

  1. Linux笔记(二) - 权限管理

    (1)改变文件或目录权限:chmod{ugoa}{+-=}{rwx}{mode=421}-R 递归修改可以同时更改多个 chmod g+w a.txt b.txt c.txt例:chmod g=rwx ...

  2. 解决 jQuery.UI.Resizable aspectRatio在init后无法重新设置

    一.背景  在jQuery1.9.x版本之前,存在aspectRatio在Resizable方法init之后,无法再次修改aspectRatio的boolean值. 二.解决方案 // 用于fix j ...

  3. H5与CS3权威下.18 and 19 选择器(1)

    18章.CSS3概述 1.从前端技术的角度把互联网的发展分为三个阶段: (1)web1.0:HTML和CSS. (2)web2.0:Ajax,Javascript/DOM/异步数据请求. (3)web ...

  4. jmeter测试dubbo接口

    本文讲解jmeter测试dubbo接口的实现方式,文章以一个dubbo的接口为例子进行讲解,该dubbo接口实现的功能为: 一:首先我们看服务端代码 代码架构为: 1:新建一个maven工程,pom文 ...

  5. java基础面向对象之类与对象

    java基础面向对象之类与对象 2017-01-14 1.面向对象的基本概念 以一种组建化的形式进行代码设计 1)在面向对象程序设计中包含有如下几种特性 •封装性:保护内部结构的安全性 •继承性:在已 ...

  6. 【锋利的Jquery】读书笔记六

    ajax优点缺点 json格式的严格 { "people": [ { "firstName": "Brett", "lastNam ...

  7. win8及win8.1商店出现0X80073CF9的解决办法!

    //添加appinstallagent无效的方法 http://jingyan.baidu.com/article/e52e3615a2b38f40c60c51d3.html

  8. java基础<迷你DVD系统>

    一.写在main方法中 import java.util.*; public class MyDVDMgr { public static void main(String[] args){ Scan ...

  9. emacs 使用教程

    http://www.cnblogs.com/liuchaogege/p/4464211.html

  10. LeetCode 213. House Robber II

    Note: This is an extension of House Robber. After robbing those houses on that street, the thief has ...