div.2/D. As Fast As Possible<数学题,二分>
题意:
n个学生出去玩,要前进一段距离,租了一辆可以载k个人的车,问到达到目的地的最短时间。
cin: n,l,v1,v2,k.
£:所有人一起到达终点的时候时间最短。
£:所有人走路和坐车的时间相等。
法一:公式推导:
•求批次:
if(n%k)
cnt=n/k+1;
else
cnt=n/k;
•设第一批人到达坐车到l1处下车,乘车时间为t1:
•车返回去接第二批人与第二批人相遇所用的时间为t2,相遇的地点为d;则第二批人走的距离和车从l1到d的距离和为l1
•车接第x批人,第x批人走的距离为(x−1)∗d,最后一批人在l−l1处被接到,直接到终点。
#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<数学题,二分>的更多相关文章
- Codeforces Round #364 (Div. 2) D. As Fast As Possible 数学二分
D. As Fast As Possible 参考:https://blog.csdn.net/keyboardmagician/article/details/52769493 题意: 一群大佬要走 ...
- 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 ...
- 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 ...
- 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
一种方法是二分总时间,复杂度O(nlogn). 另外我们可以证明,当所有人同时到达终点的时候,是最优的,因为没有人的时间“浪费”了. 我们又发现,每个人的运动过程总是两段,要么是走路,要么是坐车.于是 ...
- 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 ...
- 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 ...
- 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 ...
- 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 ...
随机推荐
- MySQL数据类型和属性
日期和时间数据类型 MySQL数据类型 含义 date 3字节,日期,格式:2014-09-18 time 3字节,时间,格式:08:42:30 datetime 8字节,日期时间,格式:2014-0 ...
- Tomcat基础
一.Tomcat体系结构 tomcat应该是java程序员最熟悉的servlet容器了,作为一个用java实现的web应用程序服务器,下图是tomcat的体系结构 一个常见的Tomcat配置文件以下x ...
- 转Delphi中Create(nil),Create(self),Create(Application)区别
Create(nil);//需要自己释放 Create(Self);//当Self释放时自动触发释放 Create(Application);//当Application释放时自动释放 Create( ...
- [ An Ac a Day ^_^ ] CodeForces 677B Vanya and Food Processor 模拟
题意: 你有一个榨汁机 还有n个土豆 榨汁机可以容纳h高的土豆 每秒可以榨k高的东西 问按顺序榨完土豆要多久 思路: 直接模拟 一开始以为是最短时间排了个序 后来发现多余了…… #include< ...
- 杭电20题 Human Gene Functions
Problem Description It is well known that a human gene can be considered as a sequence, consisting o ...
- 实验六 多线程编程 1.随便选择两个城市作为预选旅游目标。实现两个独立的线程分别显示10次城市名,每次显示后休眠一段随机时间(1000ms以内),哪个先显示完毕,就决定去哪个城市。分别用Runnable接口和Thread类实现。
//继承Thread类 package zuoye; //继承Thread类 public class City extends Thread{ private String name; public ...
- Silverlight中以客户端加载另一项目客户端(先登录后加载的一般实现)
近几日,本人在对一个老的Silverlight的GIS项目进行维护,发现该项目的实现是先把所有的资源加载至客户端,其中包括登录部分和业务实现部分,我就在想可不可以把登录部分和业务实现部分开来.如果用户 ...
- A. Brain's Photos ——Codeforces Round #368 (Div. 2)
A. Brain's Photos time limit per test 2 seconds memory limit per test 256 megabytes input standard i ...
- mysql 常用命令用法总结积木学院整理版
一.启动与退出 1.进入MySQL:启动MySQL Command Line Client(MySQL的DOS界面),直接输入安装时的密码即可.此时的提示符是:mysql> 2.退出MySQL: ...
- bash color
紫色:300A24 黄色:C4A000 Tango 紫色: 200213