WA#30
查看原帖
WA#30
957105
zzbzwjx楼主2023/8/18 16:55
#include<bits/stdc++.h>
using namespace std;
#define ld double
const ld eps=1e-6;
ld tf,vf,hf,td,vd,hd,l,r,x,ans;
int main(){
	cin>>tf>>vf>>hf>>td>>vd>>hd;
	td=td-tf;
	r=1.0*vf*sqrt(2*hf);
	ans=max(r/vf,td+r/vd)+1.0*r/vd;
	while(l+eps<r){
		x=(l+r)*0.5;
		ld t=1.0*x/vf;
		ld y=1.0*hf-0.5*t*t;
		if(hd>=y&&(t-td)>=max(1.0*x/vd,(sqrt(6.0*hd)-sqrt(6.0*hd-6.0*y))/3.0))
			r=x,ans=min(ans,t+1.0*x/vd);
		else l=x;
	}
	printf("%.5f\n",ans+tf);
}

跟着题解思路做的

2023/8/18 16:55
加载中...