题目连接

题意:

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. 浙大pat 1025题解

    1025. PAT Ranking (25) 时间限制 200 ms 内存限制 32000 kB 代码长度限制 16000 B 判题程序 Standard 作者 CHEN, Yue Programmi ...

  2. json 和 数组的区别

    json是javascript中的一种数据格式,类似于数组,但又不同于数组,区别在于下标: 例如,var obj=[a:15,b:10,c:3,d:8]: //这是json的写法 var  arr=[ ...

  3. Threading

    new System.Threading.Thread(new System.Threading.ThreadStart(ReadState)).Start();

  4. SASL - 简单认证和安全层

    转自:http://blog.csdn.net/id19870510/article/details/8232509 SASL - 简单认证和安全层 SASL是一种用来扩充C/S模式验证能力的机制认证 ...

  5. 4.编写Java应用程序。首先,定义一个时钟类——Clock,它包括三个int型 成员变量分别表示时、分、秒,一个构造方法用于对三个成员变量(时、分、秒) 进行初始化,还有一个成员方法show()用于显示时钟对象的时间。其次,再定义 一个主类——TestClass,在主类的main方法中创建多个时钟类的对象,使用这 些对象调用方法show()来显示时钟的时间。

    Clock package com.hanqi.test; public class Clock { int hour,minute,second; Clock(int h,int m,int s) ...

  6. html让背景透明

    style="z-index:100000;display:block;position:absolute;filter:progid:DXImageTransform.Microsoft. ...

  7. GetWindowRect和GetClientRect的异同

    由于项目需要,需要学习CGridCtrl控件的使用,测试控件时发现了一个问题,我无法将控件放在对话框的制定位置. 该问题的原因很容易发现,其实就是GetWindowRec()函数和GetClientR ...

  8. linex下部署发布web项目

    准备工作:通过Xmanager远程连接linux系统,下载对应的jdk和tomcat. 1.通过Xmanager远程连接linux系统,下载地址请自己网上搜索吧. 2.下载jdk (这里为jdk-7u ...

  9. 【转】解决Windows不能在本地计算机启动apache tomcat

    http://blog.163.com/ftskwsg@126/blog/static/5623853020094494117827/ 这个方法解决了我的问题. 在windows下以服务的方式启动时提 ...

  10. PHP修改记录

    1. Http请求错误--20151123 参考网址:http://www.lvtao.net/dev/php-nginx-uploadfiy.html 是配置问题,修改php.ini文件: uplo ...