fork download
  1. program chasing;
  2. Uses Math;
  3.  
  4. var
  5. Bs, Bx, By, Ds, Dx, Dy, v, spazio: LongInt;
  6. dir : Char;
  7. T, tdog, pospall : 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 = 'R') then begin tdog:=(abs(Dy-By)/Ds); pospall:=Bx+Bs*tdog; spazio:=abs(Dx-Bx); end
  23. else if (dir = 'L') then begin tdog:=(abs(Dy-By)/Ds); pospall:=Bx-Bs*tdog; spazio:=abs(Dx-Bx); end
  24. else if dir='U' then begin tdog:=(abs(Dx-Bx)/Ds); pospall:=By+ Bs*tdog; spazio:=abs(Dy-By); end
  25. else if dir='D' then begin tdog:=(abs(Dx-Bx)/Ds); pospall:=By-Bs*tdog; spazio:=abs(Dy-By); end;
  26. if ((dir = 'R') and (pospall <= Dx) and (Dx >= Bx)) or ((dir = 'L') and (Dx <= Bx) and (pospall >= Dx)) or ((dir = 'U') and (pospall <= Dy) and (Dy >= By)) or(( dir ='D') and (pospall >= Dy) and (Dy <= By))
  27. then
  28. v := Ds + Bs
  29. else
  30. v := Ds - Bs;
  31. writeln(ceil(tdog));
  32. if (v > 0) then T:=ceil(tdog+(spazio /v))
  33. else T := -1;
  34.  
  35. WriteLn(ceil(T));
  36.  
  37. end.
Success #stdin #stdout 0.01s 5316KB
stdin
7 -7 4
5 -8 3
D
stdout
1
2