fork download
  1. program chasing; (*50 punti*)
  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 begin
  28. if (dir='D') or (dir='L') then Bs:=-Bs;
  29. if (dir='R') or (dir='L') then T:= (abs(Dy-By))/Ds + (abs(Dx-Bx)) / (abs(Ds-Bs))
  30. else if (dir='U') or (dir='D') then T:= (abs(Dx-Bx))/Ds + (abs(Dy-By)) / ( abs(Ds-Bs)) ;
  31. end;
  32. (* else T:=((abs(Dx-Bx) + abs(Dy-By)) / (abs (Ds+Bs)));*)
  33.  
  34. WriteLn(ceil(T));
  35.  
  36. end.
Success #stdin #stdout 0s 5320KB
stdin
1 2 1
6 4 3
D
stdout
6