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 ...
随机推荐
- 修改weblogic中StuckThreadMaxTime参数
your_domain->Environment ->Servers ->your_server->Configuration->Tuning->Stuck Thr ...
- 聊天系统Demo,增加文件传送功能(附源码)-- ESFramework 4.0 快速上手(14)
本文我们将介绍在ESFramework 4.0 快速上手(08) -- 入门Demo,一个简单的IM系统(附源码)的基础上,增加文件传送的功能.如果不了解如何使用ESFramework提供的文件传送功 ...
- 利用scrollTop 制作图片无缝滚动
<!doctype html><title>javascript无缝滚动 by 司徒正美</title><meta charset="utf-8&q ...
- winform控件背景透明问题(label..等)
在使用winform写界面的时候,要想label这种控件实现对背景色透明,并且也懒得每次拖动一次控件都要在后台写一遍label1.Parent=PictureBox1 那么下面方法就介绍了比较简单便捷 ...
- Python 跳出多重循环
Python 本身没有“break n” 和“goto” 的语法,这也造成了Python 难以跳出多层(特定层数)循环.下面是几个跳出多层(特定层数)循环的tip. 1.自定义异常 class g ...
- C# html转mht
项目中引入cdosys.dll组件,位置: C:\Windows\System32\cdosys.dll CDO.ADODB 这些类都来自于cdosys.dll组件 /// <summary& ...
- Core Animation中的组动画
实际开发中一个物体的运动往往是复合运动,单一属性的运动情况比较少,但恰恰属性动画每次进行动画设置时一次只能设置一个属性进行动画控制(不管是 基础动画还是关键帧动画都是如此),这样一来要做一个复合运动的 ...
- 根据NSString字符串长度自动改变UILabel的frame
相信大家都遇到过这种需求.如果一个不慎,容易做成这个模样: 话不多说,上代码. 1.首先,设置UILabel的相关属性 UILabel *tmpLabel = [[UILabel alloc] ini ...
- windows禅道环境搭建
zentao官网的几个网址 http://www.zentao.net/ http://www.zentao.net/article-view-79863.html 搭建环境需要下载两个文件 1) ...
- samba配置(基础版)
1. 下载及安装Samba 推荐用yum来安装,这样它可以自己解决包的依赖关系,省时.省事又方便.一条命令搞定: yum -y install samba 2. 配置Samba 关于Samba的配 ...