题目连接

题意:

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. CSS,height:auto和height:100%有什么区别?

    auto是随内容的高度而撑开的.100%是根据父级元素的高度来决定的.例如:<div style="height:100px;width:200px;"> <di ...

  2. python 列表、字典的方法

    # 列表最后新增元素 li = [11, 22, 33] print(li) li.append(44) # 对原列表最后增加一个元素 print(li) 执行如下: [11, 22, 33][11, ...

  3. NOIP2005-普及组复赛-第三题-采药

    题目描述 Description 辰辰是个天资聪颖的孩子,他的梦想是成为世界上最伟大的医师.为此,他想拜附近最有威望的医师为师.医师为了判断他的资质,给他出了一个难题.医师把他带到一个到处都是草药的山 ...

  4. android listen

    android监听机制,应该是一种观察者模式. 摘抄网上教程,观察者模式的结构如下: 其中涉及的角色有: ● 抽象主题(Subject)角色:抽象主题角色把所有对观察者对象的引用保存在一个聚集(比如A ...

  5. 【Machine Learning in Action --5】逻辑回归(LogisticRegression)从疝气病预测病马的死亡率

    背景:使用Logistic回归来预测患有疝气病的马的存活问题,这里的数据包括368个样本和28个特征,疝气病是描述马胃肠痛的术语,然而,这种病并不一定源自马的胃肠问题,其他问题也可能引发疝气病,该数据 ...

  6. IE6下a标签失效(背景穿透)

    background:fixed url(about:blank);有时候做感应区域的时候在ie6下不给背景就会感应不到,比如说当鼠标移到图片的左半边部分,鼠标手势变成向左的箭 头,比如说有些时候a标 ...

  7. ubuntn安装五笔输入法

    1.首先要把原来的 ibus 卸载掉 sudo apt-get remove ibus 2.添加源 sudo add-apt-repository ppa:fcitx-t(www.111cn.net) ...

  8. List泛型集合常用方法

    using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace List ...

  9. 超赞的OOM检测(除了mat以外)

    今天看了下微博,扔物线分享了个内存检测的工具: 内存泄露是 OOM 最常见的原因,但它的侦测需人工排查,往往眼看瞎也未必能找到泄露的内存.Square 新库 LeakCanary 用一种巧妙的思路实现 ...

  10. ExecutorService的submit(Runnable x)和execute(Runnable x) 两个方法的本质区别

    Runnable任务没有返回值,而Callable任务有返回值.并且Callable的call()方法只能通过ExecutorService的submit(Callable <T> tas ...