题目连接

题意:

n个学生出去玩,要前进一段距离,租了一辆可以载k个人的车,问到达到目的地的最短时间。

cin: n,l,v1,v2,k.

£:所有人一起到达终点的时候时间最短。

£:所有人走路和坐车的时间相等。

法一:公式推导:

•求批次:

if(n%k)
cnt=n/k+1;
else
cnt=n/k;

•设第一批人到达坐车到l1处下车,乘车时间为t1:

l1=t1×v1=>t1=l1/v1

•车返回去接第二批人与第二批人相遇所用的时间为t2,相遇的地点为d;则第二批人走的距离和车从l1到d的距离和为l1

l1=(t1+t2)×v1+t2×v2=>t2=(l1−l1×v1/v2)/(v1+v2)

•车接第x批人,第x批人走的距离为(x−1)∗d,最后一批人在l−l1处被接到,直接到终点。

d=(t1+t2)×v1=(2×l1×v1)/(v1+v2)
l1=l×(v1+v2)/((2×cnt−1)×v1+v2)
T=l1/v2+(l−l1)/v1

#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
int n,k;
double v1,v2,l;
int main ()
{
while(~scanf("%d%lf%lf%lf%d",&n,&l,&v1,&v2,&k))
{
int cnt;
if(n%k==0)
cnt=n/k;
else
cnt=n/k+1;
double l1=l*(v1+v2)/((2*cnt-1)*v1+v2);
double ans=l1/v2+(l-l1)/v1;
printf("%.10lf\n",ans);
}
return 0;
}

div.2/D. As Fast As Possible<数学题,二分>的更多相关文章

  1. Codeforces Round #364 (Div. 2) D. As Fast As Possible 数学二分

    D. As Fast As Possible 参考:https://blog.csdn.net/keyboardmagician/article/details/52769493 题意: 一群大佬要走 ...

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

  3. Codeforces Round #372 (Div. 1) A. Plus and Square Root 数学题

    A. Plus and Square Root 题目连接: http://codeforces.com/contest/715/problem/A Description ZS the Coder i ...

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

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

  5. 【推导】Codeforces Round #364 (Div. 2) D. As Fast As Possible

    一种方法是二分总时间,复杂度O(nlogn). 另外我们可以证明,当所有人同时到达终点的时候,是最优的,因为没有人的时间“浪费”了. 我们又发现,每个人的运动过程总是两段,要么是走路,要么是坐车.于是 ...

  6. Codeforces Round #261 (Div. 2)459A. Pashmak and Garden(数学题)

    题目链接:http://codeforces.com/problemset/problem/459/A A. Pashmak and Garden time limit per test 1 seco ...

  7. Codeforces Round #379 (Div. 2) C. Anton and Making Potions 枚举+二分

    C. Anton and Making Potions 题目连接: http://codeforces.com/contest/734/problem/C Description Anton is p ...

  8. Codeforces Round #381 (Div. 2)D. Alyona and a tree(树+二分+dfs)

    D. Alyona and a tree Problem Description: Alyona has a tree with n vertices. The root of the tree is ...

  9. Codeforces Round #227 (Div. 2) E. George and Cards set内二分+树状数组

    E. George and Cards   George is a cat, so he loves playing very much. Vitaly put n cards in a row in ...

随机推荐

  1. mysql表设计---时间类型

    mysql 时间格式的区别 datetime 日期 +时间timestamp 时间戳 格式都是一样YYYY-MM-DD HH:MM:SS int(12)型存储php的time()时间戳,格式10位14 ...

  2. 把json数据 [ { } ] 转为数组

    $str = '[{"rwx_price":388.5,"end_station_name":"长沙","swz_price&qu ...

  3. mysql表设计

    model表 记录网站模块:如视频,音频,调查,01发布内容时.可以指定发布到哪个模块下02可以统计每个模块的访问量设计表注意点01主键不要用id (全部使用 当前表名+id 如modelid)02n ...

  4. Mysql表名区分大小写

    mysql数据库在windows服务器上表名和字段名均不区分大小写, 但在linux服务器上表名默认是区分大小写的,可在/etc/my.cnf文件中的[mysqld]下面加上一条配置 lower_ca ...

  5. Linux C/C++编译环境搭建

    1. 配置GCC,LInux 在安装后已经有GCC了,但可能文件不全,我们可以利用 sudo apt-get install build-essential 安装 2. 安装文本编辑器 sudo ap ...

  6. 在线用户管理--ESFramework 4.0 进阶(05)

    无论我们采用何种通信框架来构建我们的分布式系统,在服务端进行用户管理都是非常重要的一个环节.然而用户管理是否应该隶属于通信框架了?这个并不一定,通常来说,用户管理是与具体应用紧密相关的,应该是由应用解 ...

  7. chapter 13_3 table访问的元方法

    前两节的算术类.关系类运算符的元方法都为各种错误情况定义了行为,它们不会改变语言的常规行为. 但是Lua还提供了两种可以改变table行为的方法: 一种是查询table中不存在的字段.一种是修改tab ...

  8. 查看linux系统版本是32位还是64位

    如何查看ubuntu版本是64位还是32位的: 1.# uname -a 如果有x86_64就是64位的,没有就是32位的 2.# uname -mx86_64 3.# archx86_6 如何查看u ...

  9. HttpServletResponse对象(一)

    web服务器收到客户端的http请求,会针对每一次请求,分别创建一个用于代表请求的request对象,和代表响应的response对象. request和response对象既然代表请求和响应,那么我 ...

  10. java中Class对象详解

    java中把生成Class对象和实例对象弄混了,更何况生成Class对象和生成instance都有多种方式.所以只有弄清其中的原理,才可以深入理解.首先要生成Class对象,然后再生成Instance ...