题解:
我们可以看到数据量并不是很大,所以我们可以选择一秒钟一秒钟来对这个比赛进行分析
在每一秒中
要判断
1.是否有人到达终点
2.小明与小红之间的距离
/*Keep on going Never give up*/ #pragma GCC optimize(3,"Ofast","inline") #include <bits/stdc++.h> const int maxn = 1e6+10; const int MaxN = 0x3f3f3f3f; const int MinN = 0xc0c0c00c; typedef long long ll; const int mod = 100000000; using namespace std; int main() { int va,vr,t,s,l; cin>>va>>vr>>t>>s>>l; int ming=0,hong=0; int cnt=0; while(true){ if(hong>=l&&ming>=l){ cout<<"Tie "<<cnt<<endl; break; } else if(hong>=l&&ming<l){ cout<<"Hong "<<cnt<<endl; break; } else if(hong<l&&ming>=l){ cout<<"Ming "<<cnt<<endl; break; } if(ming-hong>=t){ int zz=0; while(zz<s){ zz++; cnt++; hong+=vr; if(hong>=l){ cout<<"Hong "<<cnt<<endl; return 0; } } } cnt++; hong+=vr; ming+=va; } return 0; }