赞
踩
【思路】:模拟。注意一个是在兔子歇息的时间乌龟可能到达了。刚開始没考虑WA80%。
【AC代码】:
#include
#include
#include
#include
#include
using namespace std;
int main()
{
//freopen("in.txt", "r", stdin);
//freopen("out.txt", "w", stdout);
int v1 = 0, v2 = 0, t = 0, s = 0, l = 0;
int len_t = 0, len_r = 0, cnt = 0, i = 0;
cin >> v1 >> v2 >> t >> s >> l;
while (true)
{
cnt++;
len_r += v1;
len_t += v2;
if (len_r == len_t && len_t == l)
{
cout << "D" << endl << cnt;
return 0;
}
else if (len_t == l)
{
cout << "T" << endl << cnt;
return 0;
}
else if (len_r == l)
{
cout << "R" << endl << cnt;
return 0;
}
if (len_r - len_t >= t)
{
//cnt += s;
//len_t += v2*s;
for (i = 1; i <= s; i++)
{
cnt++;
len_t += v2;
if (len_r == len_t && len_t == l)
{
cout << "D" << endl << cnt;
return 0;
}
else if (len_t == l)
{
cout << "T" << endl << cnt;
return 0;
}
else if (len_r == l)
{
cout << "R" << endl << cnt;
return 0;
}
}
}
}
}
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。