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(round(T));
  30.  
  31. end.
  32.  
Success #stdin #stdout 0.01s 5308KB
stdin
3 5 7
7 5 8
R

stdout
-1