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 (Dx<=Bx) and (Ds<=Bs) and (dir='R') then T:=-1
  23. else if (Dx>=Bx) and (Ds<=Bs) and (dir='L') then T:=-1
  24. else if (Dy>=By) and (Ds<=Bs) and (dir='D') then T:=-1
  25. else if (Dy<=By) and (Ds<=Bs) and (dir='U') then T:=-1
  26. else
  27. begin
  28. if (dir='D') or (dir='L') then Bs:=-Bs;
  29. if (abs(Dy)>abs(By)) and ((dir='D') or (dir='U')) then Ds:=-Ds;
  30. if (abs(Dx)>abs(Bx)) and ((dir='R') or (dir='L')) then Ds:=-Ds;
  31. T:=((abs(Dx-Bx) + abs(Dy-By)) / (abs (Ds+Bs)));
  32. end;
  33. WriteLn(round(T));
  34.  
  35. end.
Success #stdin #stdout 0s 5328KB
stdin
7 -7 4
7 -7 0
D
stdout
0