fork download
  1. program chasing;
  2. Uses Math;
  3.  
  4. var
  5. Bs, Bx, By, Ds, Dx, Dy : LongInt;
  6. dir : Char;
  7. T : real;
  8. begin
  9.  
  10. (* assign(input, 'input.txt'); reset(input);
  11.   assign(output, 'output.txt'); rewrite(output);*)
  12.  
  13.  
  14. ReadLn(Dx, Dy, Ds);
  15.  
  16. ReadLn(Bx, By, Bs);
  17.  
  18. ReadLn(dir);
  19.  
  20. T := 0;
  21.  
  22. if (dir='D') or (dir='L') then Bs:=-Bs;
  23. if (Dx<Bx) and (Ds<Bs) and (dir='R') then T:=-1
  24. else if (Dx>Bx) and (Ds<Bs) and (dir='L') then T:=-1
  25. else if (Dy>By) and (Ds<Bs) and (dir='D') then T:=-1
  26. else if (Dy<By) and (Ds<Bs) and (dir='U') then T:=-1
  27. else T:=((abs(Dx-Bx) + abs(Dy-By)) / (abs (Ds+Bs)));
  28.  
  29. WriteLn(ceil(T));
  30.  
  31. end.
Success #stdin #stdout 0s 5320KB
stdin
0 2 4
0 3 2
Uprogram chasing;
Uses Math;

var
     Bs, Bx, By, Ds, Dx, Dy, T,  dist   : LongInt;
     dir : Char;
     tdog,spostpall,nuovacoordpall : real;
begin

    assign(input,  'input.txt');  reset(input);
    assign(output, 'output.txt'); rewrite(output);


    ReadLn(Dx, Dy, Ds);

    ReadLn(Bx, By, Bs);

    ReadLn(dir);

    
    if dir='L' then T:= ceil((abs(Dx-Bx) + abs(Dy-By))/(abs(Ds+Bs)));
  writeln(T);
end.
stdout
1