解答代码
#include<iostream>#include<string>#include<cstdio>#include<cstring>#include<set>#include<cmath>#define N 100using namespace std;int main(){ float v1,v2,t,s,len; cin>>v1>>v2>>t>>s>>len; int t1=0,t2=0; int s1=0,s2=0; while(s1<len && s2<len) { if(s1-s2>=t) { t2+=s; s1=v1*t1; s2=v2*t2; } else { t1++; t2++; s1=v1*t1; s2=v2*t2; } } if(s1<s2) cout<<"T"<<endl<<len/v2<<endl;//乌龟 else if(s1==s2) cout<<"D"<<endl<<t2<<endl; else cout<<"R"<<endl<<t2<<endl;//兔子 return 0;}
新闻热点
疑难解答