Codeforces Round #364 (Div. 2) D 数学/公式
1 second
256 megabytes
standard input
standard output
On vacations n pupils decided to go on excursion and gather all together. They need to overcome the path with the length l meters. Each of the pupils will go with the speed equal to v1. To get to the excursion quickly, it was decided to rent a bus, which has seats for k people (it means that it can't fit more than k people at the same time) and the speed equal to v2. In order to avoid seasick, each of the pupils want to get into the bus no more than once.
Determine the minimum time required for all n pupils to reach the place of excursion. Consider that the embarkation and disembarkation of passengers, as well as the reversal of the bus, take place immediately and this time can be neglected.
The first line of the input contains five positive integers n, l, v1, v2 and k (1 ≤ n ≤ 10 000, 1 ≤ l ≤ 109, 1 ≤ v1 < v2 ≤ 109, 1 ≤ k ≤ n) — the number of pupils, the distance from meeting to the place of excursion, the speed of each pupil, the speed of bus and the number of seats in the bus.
Print the real number — the minimum time in which all pupils can reach the place of excursion. Your answer will be considered correct if its absolute or relative error won't exceed 10 - 6.
5 10 1 2 5
5.0000000000
3 6 1 2 1
4.7142857143
In the first sample we should immediately put all five pupils to the bus. The speed of the bus equals 2 and the distance is equal to 10, so the pupils will reach the place of excursion in time 10 / 2 = 5.、
题意:n个学生 走长度为l的行程 步行速度为v1 公车的速度v2 车上有k个位置 求最少的时间使得所有的学生到达终点;
题解:考虑什么是最优的情况呢?应该使得汽车最少的时间空车行驶,使得所有的学生坐车时间和步行时间应该相同
并且同时到达终点

上图为最优情况下 汽车的运动轨迹 保证所有的学生同时到达终点
每一个子运动的distance=v2*t-(v2-v1)/(v2+v1)*t*v2;
(t为运送第一批学生停车的时刻,返程为汽车与其余学生的相向运动)
可以发现l=p*v2*t-(v2-v1)/(v2+v1)*t*v2*(p-1); (p为学生的批数)
从而推导出t=l/(p*v2-(v2-v1)/(v2+v1)*v2*(p-1))
因为所有的学生同时到达 所以选择第一批学生计算总时间(l-v2*t)/v1+t (步行时间+坐车时间)
@dream-boy
//code by drizzle
#include<bits/stdc++.h>
#include<iostream>
#include<cstring>
#include<cstdio>
#define ll __int64
#define PI acos(-1.0)
#define mod 1000000007
using namespace std;
int n,k;
double l,v1,v2;
int p;
int main()
{
scanf("%d %lf %lf %lf %d",&n,&l,&v1,&v2,&k);
double L=;
p=n/k;
if((n%k)>)
p++;
L=l/(p*v2-(v2-v1)/(v2+v1)*v2*(p-));
printf("%.7f\n",(l-v2*L)/v1+L);
return ;
}
Codeforces Round #364 (Div. 2) D 数学/公式的更多相关文章
- 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 数学二分
D. As Fast As Possible 参考:https://blog.csdn.net/keyboardmagician/article/details/52769493 题意: 一群大佬要走 ...
- Codeforces Round #364 (Div. 2)
这场是午夜场,发现学长们都睡了,改主意不打了,第二天起来打的virtual contest. A题 http://codeforces.com/problemset/problem/701/A 巨水无 ...
- 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 #364 (Div.2) C:They Are Everywhere(双指针/尺取法)
题目链接: http://codeforces.com/contest/701/problem/C 题意: 给出一个长度为n的字符串,要我们找出最小的子字符串包含所有的不同字符. 分析: 1.尺取法, ...
- 树形dp Codeforces Round #364 (Div. 1)B
http://codeforces.com/problemset/problem/700/B 题目大意:给你一棵树,给你k个树上的点对.找到k/2个点对,使它在树上的距离最远.问,最大距离是多少? 思 ...
- Codeforces Round #372 (Div. 2) C 数学
http://codeforces.com/contest/716/problem/C 题目大意:感觉这道题还是好懂得吧. 思路:不断的通过列式子的出来了.首先我们定义level=i, uplevel ...
- Codeforces Round #546 (Div. 2) E 推公式 + 线段树
https://codeforces.com/contest/1136/problem/E 题意 给你一个有n个数字的a数组,一个有n-1个数字的k数组,两种操作: 1.将a[i]+x,假如a[i]+ ...
- A. Little C Loves 3 I Codeforces Round #511 (Div. 2) 【数学】
题目: Little C loves number «3» very much. He loves all things about it. Now he has a positive integer ...
随机推荐
- NUMA的原理与局限
为什么要有NUMA 在NUMA架构出现前,CPU欢快的朝着频率越来越高的方向发展.受到物理极限的挑战,又转为核数越来越多的方向发展.如果每个core的工作性质 都是share-nothing(类似于m ...
- python Scraping
http://docs.python-guide.org/en/latest/scenarios/scrape/
- Vim编辑器基础命令
Linux系统中都默认安装了vi或vim编辑器,两种命令基本一致.vim为Vi IMproved,功能更强大. vim有命令模式,输入模式,和末行模式三种. ➢ 命令模式:控制光标移动,可对文本进行复 ...
- django项目实现第三方github登录
OAuth(开放授权 Open Authorization)是一个开放标准,允许用户授权第三方网站访问他们存储在另外的服务提供者上的信息,而不需要将用户名和密码提供给第三方网站或分享他们数据的所有内容 ...
- Android 性能篇 -- 带你领略Android内存泄漏的前世今生
基础了解 什么是内存泄漏? 内存泄漏是当程序不再使用到的内存时,释放内存失败而产生了无用的内存消耗.内存泄漏并不是指物理上的内存消失,这里的内存泄漏是指由程序分配的内存但是由于程序逻辑错误而导致程序失 ...
- JZOJ 3461. 【NOIP2013模拟联考5】小麦亩产一千八(kela)
3461. [NOIP2013模拟联考5]小麦亩产一千八(kela) (Standard IO) Time Limits: 1000 ms Memory Limits: 262144 KB Det ...
- Visual Studio的下载安装
下载地址: 下载Visual Studio Code https://code.visualstudio.com/ 安装扩展包 安装图标 View->Extensions 搜索Icon 安装Ma ...
- 第1-5章 慕课网微信小程序开发学习笔记
第1章 前言:不同的时代,不同的Web --微信小程序商城构建全栈应用 http://note.youdao.com/noteshare?id=a0e9b058853dbccf886c1a890594 ...
- linux 查看CPU内存 网络 流量 磁盘 IO
使用vmstat命令来察看系统资源情况 在命令行方式下,如何查看CPU.内存的使用情况,网络流量和磁盘I/O? Q: 在命令行方式下,如何查看CPU.内存的使用情况,网络流量和磁盘I/O? A: 在命 ...
- Linux命令之---nl
命令简介 nl命令在linux系统中用来计算文件中行号.nl 可以将输出的文件内容自动的加上行号!其默认的结果与 cat -n 有点不太一样, nl 可以将行号做比较多的显示设计,包括位数与是否自动补 ...