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