fork download
  1. program chasing;
  2. Uses Math;
  3.  
  4. var
  5. Bs, Bx, By, Ds, Dx, Dy, posizione : LongInt;
  6. dir : Char;
  7. T, tdogoriz,tdogvert, tdog, spaziopall, spvert, sporiz, spazio : 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; tdog:=1;
  21. sporiz:= abs(Dx-Bx); spvert:=abs(Dy-By);
  22. tdogoriz:=sporiz / Ds; tdogvert:=spvert / Ds;
  23. spaziopall:= Bs*tdog;
  24.  
  25. if ((Dx>Bx) and (Dy>By)) then posizione:=1
  26. else if ((Dx>Bx) and (Dy<By)) then posizione:=4
  27. else if ((Dx<Bx) and (Dy>By)) then posizione:=2
  28. else if ((Dx<Bx) and (Dy<By)) then posizione:=3;
  29. if ((posizione=1) or (posizione=4)) and (dir='R') and (spaziopall<=sporiz) then
  30. begin
  31. spazio:=sporiz; tdog:=tdogvert;
  32. Ds:=-Ds; spaziopall:=-spaziopall;
  33. end
  34. else
  35. if ((posizione=1) or (posizione=4)) and (dir='R') and (spaziopall>sporiz) then
  36. if (Ds>Bs) then begin spazio:=sporiz; tdog:=tdogvert; end
  37. else begin writeln(-1); exit;end;
  38.  
  39.  
  40. T:=tdog+ (spazio+spaziopall) / (abs(Ds-Bs)) ;
  41. if T>0 then WriteLn(ceil(T))
  42. else writeln(-1);
  43.  
  44. end.
  45.  
Success #stdin #stdout 0s 5316KB
stdin
7 -9 1
5 -8 2
R
stdout
1