蓝桥杯之龟兔赛跑预测

来源:互联网 发布:java线程死锁例子 编辑:程序博客网 时间:2024/05/17 02:06
#include <iostream>using namespace std;int main(){    int v1,v2,t,s,l;    cin>>v1>>v2>>t>>s>>l;    int time1=l/v2;    int time2=l/v1;    int dis1=0;    int dis2=0;    int i=1;    while(i<time1){        if(dis1-dis2>=t){            i=i+s;            time2+=s;            dis2+=v2*s;        }        else{            i++;            dis1+=v1;            dis2+=v2;        }    }    if(time2==time1){        cout<<'D'<<endl;        cout<<time2<<endl;    }    if(time2>time1){        cout<<'T'<<endl;        cout<<time1<<endl;    }    if(time2<time1){        cout<<'R'<<endl;        cout<<time2<<endl;        }    return 0;}



0 0
原创粉丝点击