Run ID | 作者 | 问题 | 语言 | 测评结果 | 时间 | 内存 | 代码长度 | 提交时间 |
---|---|---|---|---|---|---|---|---|
60480 | wangwei | 龟兔赛跑预测 | C++ | 通过 | 0 MS | 256 KB | 794 | 2025-01-25 09:16:46 |
#include <bits/stdc++.h> using namespace std; int main() { //l是总距离 int v1, v2, t, s, l, i = 0; int ans1 = 0, ans2 = 0; //分别龟兔走过的路程 cin>>v1>>v2>>t>>s>>l; while(ans1 < l && ans2 < l) { ans1 += v1 * 1; //兔子1s内走过的距离 ans2 += v2 * 1; i ++; //秒数 if(ans1 == l || ans2 == l) break; //说明有人已经到达终点 if(ans1 - ans2 >= t) ans1 -= s * v1; //兔子停下来休息,休息的这段时间里兔子有s*v1的距离是没走的。 } if(ans1 > ans2) cout<<"R"<<endl; else if(ans1 < ans2) cout<<"T"<<endl; else cout<<"D"<<endl; cout<<i; return 0; }