2 solutions

  • 0
    @ 2024-10-21 17:12:37

    #include <stdio.h> int main() { int v1,v2,t,s,l; int x1=0,x2=0,i=0; scanf("%d %d %d %d %d",&v1,&v2,&t,&s,&l); while(x1<l&&x2<l){ x1=x1+v1; x2=x2+v2; i++; if(x1l||x2l){ break; } if(x1-x2>=t){ x1-=v1*s; } } if(x1>x2){ printf("R\n"); printf("%d",i); } else if(x1==x2){ printf("D\n"); printf("%d",i); } else{ printf("T\n"); printf("%d",i); }
    return 0; }

    • 0
      @ 2023-10-25 18:10:05
      #include<bits/stdc++.h>
      using namespace std;
      int main(){
          int v1,v2,t,s,l;
          cin>>v1>>v2>>t>>s>>l;
          int t_W=0;
          int t_R=0;
          int dis_R=0;
          int dis_W=0;
          while(dis_R<l&&dis_W<l){
              int k=dis_R-dis_W;
              if(k>=t){
                   dis_W+=s*v2;
                   t_R+=s;
                   t_W+=s;
                   continue;//很重要,不然只能跑80%数据,跳到下次循环
              }       
              dis_R+=v1;
              dis_W+=v2;
              t_R++;
              t_W++;
          }
      
          if(dis_R<l){
              cout<<"T"<<endl;
              cout<<t_W;
          }else if(dis_W<l){
              cout<<"R"<<endl;
              cout<<t_R;
          }
          else cout<<"D"<<endl<<t_W;
          
          return 0;
      }
      
      • 1

      Information

      ID
      6819
      Time
      1000ms
      Memory
      256MiB
      Difficulty
      8
      Tags
      # Submissions
      67
      Accepted
      11
      Uploaded By