题目连接

题意:

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. 索引图像(X与map)的显示、保存、转化

    有的图像载入后,出现X.map两个矩阵,那么他就是索引图像. load wbarb; figure,imshow(X,map);%显示原图 imwrite(X,map,'C:\Users\Jv\Des ...

  2. 修改weblogic中StuckThreadMaxTime参数

    your_domain->Environment ->Servers ->your_server->Configuration->Tuning->Stuck Thr ...

  3. ESFramework 4.0 快速上手(06) -- Rapid引擎(续)

    <ESFramework 4.0 快速上手>系列介绍的都是如何使用Rapid引擎(快速引擎) -- RapidServerEngine 和 RapidPassiveEngine.其实,大家 ...

  4. Sersync同步过滤.svn文件夹

    Sersync同步过滤.svn文件夹 <filter start="true"> <exclude expression="(.*).svn(.*)&q ...

  5. 【python问题系列--4】ValueError: operands could not be broadcast together with shapes (100,3) (3,1)

    背景:dataMatrix是(100,3)的列表,labelMat是(1,100)的列表,weights是(3,1)的数组,属性如下代码所示: >>> import types> ...

  6. iOS UITextView 根据输入text自适应高度

    转载自:http://www.cnblogs.com/tmf-4838/p/5380495.html #import "ViewController.h" @interface V ...

  7. npm常用指令

    安装: npm install <name> npm install <name> 安装依赖包,默认安装最新版本,也可在后面加上版本号,并且将安装信息加入项目的package. ...

  8. Sqoop 将hdfs上的文件导入到oracle中,关于date类型的问题

    近期的项目中,需要将hadoop运行完成的结果(存在于hdfs上)导入到oracle中,但是在用sqoop导入hdfs中的日期字段'2016-03-01'时,sqoop报错,说date类型必须为'yy ...

  9. SpringMVC 学习-如何搭配使用 Velocity 页面模板

    一.快速搭建 Velocity 框架 1. 加入所需 Jar 包 <dependency> <groupId>org.apache.velocity</groupId&g ...

  10. MFC中MessageBeep与sndPlaySound播放声音函数使用

    MessageBeep(0x00000000L);    //用来播放系统默认音频文件,如0x00000000L为系统提示音,具体音频对应规则,请参照MSDN. sndPlaySound函数用来播放指 ...