题目链接:

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 to v1. To get to the excursion quickly, it was decided to rent a bus, which has seats for kpeople (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 exceed 10 - 6.

Examples
input
5 10 1 2 5
output
5.0000000000
input
3 6 1 2 1
output
4.7142857143

题意:

现在给了两个速度,n个人,长为l的路,车的速度快,人的速度,车的容量为k;
现在问这n个人走完l的路后用时最少是多少; 思路: 我是二分车第一次载人的时长,计算最后一次载人是否恰好到达终点;
精度被卡我就把二分的次数上限限定了才过,好像直接有公式; AC代码:
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <bits/stdc++.h>
#include <stack> using namespace std; #define For(i,j,n) for(int i=j;i<=n;i++)
#define mst(ss,b) memset(ss,b,sizeof(ss)); typedef long long LL; template<class T> void read(T&num) {
char CH; bool F=false;
for(CH=getchar();CH<'0'||CH>'9';F= CH=='-',CH=getchar());
for(num=0;CH>='0'&&CH<='9';num=num*10+CH-'0',CH=getchar());
F && (num=-num);
}
int stk[70], tp;
template<class T> inline void print(T p) {
if(!p) { puts("0"); return; }
while(p) stk[++ tp] = p%10, p/=10;
while(tp) putchar(stk[tp--] + '0');
putchar('\n');
} const LL mod=1e9+7;
const double PI=acos(-1.0);
const int inf=1e9;
const int N=1e5+10;
const int maxn=500+10;
const double eps=1e-14; int n,k;
double L,v1,v2; int check(double x)
{
double t=x,pos=v2*t;
For(i,2,n)
{
double tempt=t,temppos=pos;
pos=(temppos-tempt*v1)*v2/(v2-v1)+(temppos-tempt*v1)*v1/(v1+v2)+tempt*v1;
t=(temppos-tempt*v1)/(v2-v1)+(temppos-tempt*v1)/(v1+v2)+tempt;
}
if(pos>=L)return 0;
return 1;
} int main()
{
scanf("%d%lf%lf%lf%d",&n,&L,&v1,&v2,&k);
if(k>=n)printf("%.10lf",L/v2);
else
{
if(n%k==0)n=n/k;
else n=n/k+1;
double l=0,r=L/v2;
int cnt=0;
while(r>=l+eps&&cnt<1000)
{
cnt++;
double mid=(l+r)/2;
if(check(mid))l=mid;
else r=mid;
}
r=(l+r)/2;
double ans=(L-r*v2)/v1+r;
printf("%.10lf\n",ans);
}
return 0;
}

  

codeforces 701D D. As Fast As Possible(数学)的更多相关文章

  1. 【45.61%】【codeforces 701D】As Fast As Possible

    time limit per test1 second memory limit per test256 megabytes inputstandard input outputstandard ou ...

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

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

  3. Codeforces Round #364 (Div. 2) D. As Fast As Possible 数学二分

    D. As Fast As Possible 参考:https://blog.csdn.net/keyboardmagician/article/details/52769493 题意: 一群大佬要走 ...

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

  5. Codeforces Educational Codeforces Round 5 E. Sum of Remainders 数学

    E. Sum of Remainders 题目连接: http://www.codeforces.com/contest/616/problem/E Description The only line ...

  6. Codeforces Round #207 (Div. 1)B(数学)

    数学so奇妙.. 这题肯定会有一个循环节 就是最小公倍数 对于公倍数内的相同的数的判断 就要借助最大公约数了 想想可以想明白 #include <iostream> #include< ...

  7. Codeforces 810C Do you want a date?(数学,前缀和)

    C. Do you want a date? time limit per test:2 seconds memory limit per test:256 megabytes input:stand ...

  8. codeforces 2B The least round way(DP+数学)

    The least round way 题目链接:http://codeforces.com/contest/2/problem/B ——每天在线,欢迎留言谈论.PS.本题有什么想法.建议.疑问 欢迎 ...

  9. Codeforces Round #499 (Div. 2) C. Fly(数学+思维模拟)

    C. Fly time limit per test 1 second memory limit per test 256 megabytes input standard input output ...

随机推荐

  1. sqlite数据库转换为mysql数据库

    SQLite工具我用的SQLiteStudio2.1.5 下载地址 http://sqlitestudio.pl/?act=download SQLiteStudio打开数据库文件,点工具->导 ...

  2. 修改 百度地图 infowindow 默认样式

    1.百度 api 没有 提供可以修改 infowindow 默认样式的 方法. 如需修改,需要 自定义 替换 默认样式. demo.html <!DOCTYPE html> <htm ...

  3. C中的预编译编译链接

        http://ke.qq.com/webcourse/index.html#course_id=67888&term_id=100058920&taid=13934591901 ...

  4. 如何去掉Google搜索的跳转 让你的Google搜索不被reset掉

    http://www.nowamagic.net/librarys/veda/detail/389 在点击google搜索结果时,google会在结果的URL前做个跳转,且有时这个跳转地址会被墙,这样 ...

  5. C#中??和?分别是什么意思? 在ASP.NET开发中一些单词的标准缩写 C#SESSION丢失问题的解决办法 在C#中INTERFACE与ABSTRACT CLASS的区别 SQL命令语句小技巧 JQUERY判断CHECKBOX是否选中三种方法 JS中!=、==、!==、===的用法和区别 在对象比较中,对象相等和对象一致分别指的是什么?

    C#中??和?分别是什么意思? 在C#中??和?分别是什么意思? 1. 可空类型修饰符(?):引用类型可以使用空引用表示一个不存在的值,而值类型通常不能表示为空.例如:string str=null; ...

  6. oracle ORA-06550

    declare  cnt integer; begin     select count(0)     into cnt     from user_all_tables    where table ...

  7. 获取当前外网IP地址

    <script src="http://pv.sohu.com/cityjson?ie=utf-8"></script><script>cons ...

  8. java 连接mysql 和sql server2008代码

    这两天用java分别连接mysql和sql server2008代码.刚開始都是有错.如今找到了在 自己机器上成功连接的代码: 1. mysql Class.forName("com.mys ...

  9. Openlayers中layer介绍

    1.base layers & overlay layers base layer:最底层的layer,其它的图层是在他之上,最先增加的图层默认作为base layer. overlay la ...

  10. php跳转

    header("Location: http://bbs. lampbrother.net"); header("refresh:0;url=./login.php&qu ...