参考:题解1476:[蓝桥杯][基础练习VIP]龟兔赛跑预测 (C语言描述)
#include<bits/stdc++.h>
using namespace std;
int main(){
float v1,v2,t,s,l;//s-time|t-meter
cin>>v1>>v2>>t>>s>>l;
int i=0;
int w=0;//w is waiting time
long long s1=0;
long long s2=0;
//they start at the same time
for(i=1;s1<l&&s2<l;i++){
w--;
if(s1-s2<t&&w<=0){
s1=s1+v1;
s2=s2+v2;
}
else{
if(w<=0) w=s;// w is waiting time
s2=s2+v2;
}
}
if (s1 > s2)
cout<<'R'<<endl;
else if (s1 == s2)
cout<<'D'<<endl;
else
cout<<'T'<<endl;
cout<<i-1<<endl;
return 0;
}