二分答案
#include<bits/stdc++.h> using namespace std; #define ll long long int n,l,v1,v2,k; double judge(double mid){//在mid时间内走完 if(mid*v2<l)return 0; double t=mid-(v2*mid-l)/(v2-v1);//每人坐车t分钟 double rt=t*(v2-v1)/(v1+v2);//回去的时间 int num=n/k;//送的批数 if(n%k)num++; double tot=num*t+(num-1)*rt; if(tot<mid)return 1; return 0; } int main(){ cin>>n>>l>>v1>>v2>>k; double L=0,R=1e10,ans,mid; while(R-L>1e-6){ mid=(L+R)/2; if(judge(mid)) ans=mid,R=mid; else L=mid; } printf("%.10lf ",ans); }