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) 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) and (dir='R') and (spaziopall>=sporiz) then
  36. begin
  37. spazio:=sporiz; tdog:=tdogvert;
  38. end;
  39.  
  40.  
  41. T:=tdog+ (spazio+spaziopall) / (abs(Ds-Bs)) ;
  42. if T>0 then WriteLn(ceil(T))
  43. else writeln(-1);
  44.  
  45. end.
Success #stdin #stdout 0.01s 5288KB
stdin
3 5 2
1 -3 5
R
stdout
5