701 D. As Fast As Possible

###链接
http://codeforces.com/group/1EzrFFyOc0/contest/701/problem/D
###题意 
n个人,走lm,有车但没人只能坐一次,车容量为k,人速度v1,车速度v2,问所有人走完需要的最小时间
###分析
其实是个数学问题 
###代码

#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main(){
    ll n,l,v1,v2,k;
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    //freopen("in.txt","r",stdin);
    while(cin>>n>>l>>v1>>v2>>k){
        ll m=n/k+(n%k>0);
        ll cnt=m-1;
        double i=v2*1.0*(m-cnt*(v2-v1)*1.0/(v1+v2));
        double t2=l*1.0/i;
        double t1=1.0*(l-t2*v2)/v1;
        double ans=t1+t2;
        printf("%.10f\n",ans);
    }
    return 0;
}

猜你喜欢

转载自www.cnblogs.com/mch5201314/p/9497940.html