CF148B Escape - 1500

VJ传送门

题目思路

直接模拟。

注意到时间有可能不为整数。大胆用 double 去做。

AC Code

#include<bits/stdc++.h>
using namespace std;
double vp,vd,t,f,c;
int ans;
signed main(){
	ios::sync_with_stdio(0),cin.tie(0);
	cin>>vp>>vd>>t>>f>>c;
	if(vp>vd)	return puts("0"),0;
	double np=vp*t,nd=0;
	while(np<c){
		if(nd<np){
			double t1=(np-nd)/(vd-vp);
			nd+=vd*t1;np+=vp*t1;
		}
		if(abs(nd-np)<=1e-9){
			if(np<c)	ans++;
			np+=((nd/vd)+f)*vp;
			nd=0;
		}
	}
	cout<<ans;
	return 0;
}
posted @ 2026-04-06 21:49  深申  阅读(5)  评论(0)    收藏  举报