蓝桥杯练习题—— 龟兔赛跑预测

  /*
**************************************************
    Title: 蓝桥杯练习题—— 龟兔赛跑预测
**************************************************
    Date:2014/03/12
**************************************************
    author:刘旭
**************************************************
 */
#include
using namespace std;
int main()
{
    int v1, v2, t, s, l;
    int l1,l2,t1,t2,time = 0;
    cin>>v1>>v2>>t>>s>>l;
    t1 = t2 = 0;
    l1 = l2 = 0;
    while(l1 < l && l2 < l)
    {
        if(l1 - l2 >= t)
        {
            t2 += s;
            l1 = v1 * t1;
            l2 = v2 * t2;
        }
        else
        {
            t1++;
            t2++;
            l1 = v1 * t1;
            l2 = v2 * t2;
        }
    }
    if(l1 == l2)
        cout<<"D"< l2)
        cout<<"R"<

你可能感兴趣的:(蓝桥杯练习)