题意:一群学生,要到离这里为l的地方去。有一辆车,车只有k个座位。人和车的速度分别v1,v2,问你所有人到达的最小时间。

思路:数学题。最小时间就是要求所有同学同时到达。每个同学最多上一次车。那么显然总路程就是车走一段,人走一段,且每个同学两个距离相等。

那么怎么求呢?设每个人坐车距离为l1,步行就是l-l1,算一下一共需要车来回接多少次学生,记为cnt。

第一组学生上车地点在0处。然后会坐车往前 走l1,车再回来,去接后面的同学。

设第二组同学上车地点在d处。首先在车走到l1处时,所用的时间为t1=l1/v2。此时第二组和车相差距离d1=l1*(1-v1/v2)。那么相遇的时间t2=d1/(v1+v2)

那么第二组同学上车地点d会等于d=(t1+t2)*v1=2*v1*l1/(v1+v2).然后发生什么呢?车子往前走l1,再回来借第三组学生。

等等?这个过程是不是很眼熟?没错,和第一次是一样的。

所以每次前进的距离也是一样的。那么最后一组同学上车的位置也就是2*(cnt-1)*v1*l1/(v1+v2),同时也等于l-l1。

联立一下求出l1.T=l1/v2+(l-l1)/v2。

一定要注意精度问题!!!!  不是很明白的建议画个图一步步推一推。

 
D. As Fast As Possible
time limit per test

1 second

memory limit per test

256 megabytes

input

standard input

output

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 tov1. 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.

Input

The first line of the input contains five positive integers nlv1, 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.

Output

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 exceed10 - 6.

Examples
input
5 10 1 2 5
output
5.0000000000
input
3 6 1 2 1
output
4.7142857143
#include<iostream>
#include<stdio.h>
using namespace std;
int main(){
int n,l,v1,v2,k;
scanf("%d%d%d%d%d",&n,&l,&v1,&v2,&k);
int cnt=n/k;
if(n%k) cnt++;
double fenzi= (double)l*(v1+v2);
double fenmu = (double)(*v1*(cnt-)+v1+v2);
double l1=fenzi/fenmu;
double ans=(l1/v2)+(double(l-l1)/v1);
printf("%.12lf\n",ans);
return ;
}
 

codeforces #364d As Fast As Possible的更多相关文章

  1. [Codeforces 364D]Ghd(随机算法+gcd)

    [Codeforces 364D]Ghd(随机算法) 题面 给出n个正整数,在其中选出n/2(向上取整)个数,要求这些数的最大公约数最大,求最大公约数的最大值 分析 每个数被选到的概率\(\geq \ ...

  2. Codeforces 700A As Fast As Possible(二分答案)

    [题目链接] http://codeforces.com/problemset/problem/700/A [题目大意] 有一辆限载k人速度为v2的车,n个步行速度均为v1的人要通过一段长度为l的距离 ...

  3. codeforces 700A As Fast As Possible 二分求和?我觉得直接解更好

    分析:一辆车最多载k个人,车的速度肯定比人快,所以想要到达时间最短,那么每个人必须做一次公交车.那么把n个人分成p=(n+k-1)/k组.设最短时间为t,每人乘车时间为t1,则t1*v2+(t-t1) ...

  4. CodeForces 700A As Fast As Possible

    要保证总时间最短,因为总时间计的是最后一个人到达的时间,也就是最后一个人要求尽快到达,也就是说我们要让最后一个人乘车时间尽量多.再仔细想想可以发现每个人的乘车时间和走路时间都是一样的. 因此,可以二分 ...

  5. codeforces 700a//As Fast As Possible// Codeforces Round #364(Div. 1)

    题意:n个人要运动ll长,有个bus带其中几个人,问最短时间 最后所有人在同一时间到终点是用时最少的.由于搭bus相当于加速,每个人的加速时间应该一样.先计算bus走过的路程route.看第一个人被搭 ...

  6. Codeforces 364D 随机算法

    题意:给你一个序列,定义ghd为一个序列中任意n / 2个数的gcd中最大的那个,现在问这个序列的ghd为多少. 思路:居然是论文题...来自2014年国家集训队论文<随机化算法在信息学竞赛中的 ...

  7. codeforces364D

    Ghd CodeForces - 364D John Doe offered his sister Jane Doe find the gcd of some set of numbers a. Gc ...

  8. Codeforces 866C Gotta Go Fast - 动态规划 - 概率与期望 - 二分答案

    You're trying to set the record on your favorite video game. The game consists of N levels, which mu ...

  9. [Codeforces 865C]Gotta Go Fast(期望dp+二分答案)

    [Codeforces 865C]Gotta Go Fast(期望dp+二分答案) 题面 一个游戏一共有n个关卡,对于第i关,用a[i]时间通过的概率为p[i],用b[i]通过的时间为1-p[i],每 ...

随机推荐

  1. UVA 1025 A Spy in the Metro 【DAG上DP/逆推/三维标记数组+二维状态数组】

    Secret agent Maria was sent to Algorithms City to carry out an especially dangerous mission. After s ...

  2. 关于Date数据类型格式化的转换

    例如:   jsp页面读取数据库中日期格式的列时可能显示为1988-05-03 00:00:00 格式,但是我们不想要后面的00:00:00时间,只想要前面的年月日,那么该如何做出修改呢? 方法一:我 ...

  3. 洛谷——P2067 Cytus-Holyknight

    P2067 Cytus-Holyknight 题目背景 本人最初作 以此纪念伟大的ios.安卓.PSV平台音乐游戏<cytus> 后续将不断更新. -------------Chapter ...

  4. Editing 2011-2012 ACM-ICPC Northeastern European Regional Contest (NEERC 11)

    NEERC 11 *wiki链接[[https://acm.ecnu.edu.cn/wiki/index.php?title=2011-2012_ACM-ICPC_Northeastern_Europ ...

  5. 十. 图形界面(GUI)设计2.框架窗口

    窗口是GUI编程的基础,小应用程序或图形界面的应用程序的可视组件都放在窗口中,在GUI中,窗口是用户屏幕的一部分,起着在屏幕中一个小屏幕的作用.有以下三种窗口: Applet窗口:Applet类管理这 ...

  6. Android Developer -- Bluetooth篇 概述

    Bluetooth 安卓平台支持蓝牙网络协议栈,它允许设备与其他蓝牙设备进行无线交换数据.应用程序框架通过安卓蓝牙APIs提供访问蓝牙功能.这些APIs使应用程序通过无线连接到其他蓝牙设备,使点对点和 ...

  7. C#中 protected internal 和 internal 的区别

    http://kudick.blog.163.com/blog/static/1666066320091055414453/ DoDo: protected: 爷爷有一张银行卡,爸爸可以用,儿子也可以 ...

  8. Hive错误记录

    创建表报错 Error: Error while processing statement: FAILED: Execution Error, return code 1 from org.apach ...

  9. ECSHOP去版权(删除ECSHOP所有标识)

    前台部分: 1:去掉头部TITLE部分的ECSHOP演示站 Powered by ecshop前者”ECSHOP演示站”在后台商店设置 – 商店标题修改后者” Powered by ecshop”打开 ...

  10. Powershell 远程管理

    一直使用 mstsc,为了防止墨菲定律,准备一些备用方案 环境,win10 to win12 winrm是windows 一种方便远程管理的服务: 首先要开启winrm service,便于在日常工作 ...