fork download
  1. program chasing;
  2. Uses Math;
  3.  
  4. var
  5. Bs, Bx, By, Ds, Dx, Dy, T, dist : LongInt;
  6. dir : Char;
  7. tdog,spostpall,nuovacoordpall : 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. if dir='R' then
  22. begin
  23. dist:=abs(Dx-Bx);
  24. tdog:=abs(Dy-By)/Ds; writeln(tdog);
  25. spostpall:=Bs*tdog;
  26. nuovacoordpall:=Bx+spostpall;
  27. if nuovacoordpall<=Dx then Ds:=-Ds
  28. else if Ds<Bs then begin writeln(-1); exit; end;
  29. T:=ceil(tdog+(abs(dist-spostpall))/(abs(Ds-Bs)));
  30. end;
  31. if dir='L' then
  32. begin
  33. BS:=-Bs;
  34. dist:=abs(Dx-Bx);
  35. tdog:=abs(Dy-By)/Ds;
  36. spostpall:=Bs*tdog;
  37. nuovacoordpall:=Bx+spostpall;
  38. if nuovacoordpall<=Dx then begin if Ds<abs(Bs) then begin writeln(-1); exit; end
  39. else Ds:=-Ds;
  40. end;
  41.  
  42. T:=ceil(tdog+(abs(dist-spostpall))/(abs(Ds-Bs)));
  43. end;
  44. if dir='D' then
  45. begin
  46. BS:=-Bs;
  47. dist:=abs(Dy-By); writeln(dist);
  48. tdog:=(abs(Dx-Bx)/Ds); writeln(tdog);
  49. spostpall:=Bs*tdog; writeln(spostpall);
  50. nuovacoordpall:=By+spostpall;
  51. if nuovacoordpall<=Dy then begin if Ds<abs(Bs) then begin writeln(-1); exit; end
  52. else Ds:=-Ds;
  53. end;
  54.  
  55. T:=ceil(tdog+ (abs(nuovacoordpall-Dy))/(abs(Ds-Bs)));
  56. end;
  57. if dir='U' then
  58. begin
  59. dist:=abs(Dy-By);
  60. tdog:=ceil(abs(Dx-Bx)/Ds);
  61. spostpall:=Bs*tdog;
  62. nuovacoordpall:=By+spostpall;
  63. if nuovacoordpall>Dy then begin if Ds<Bs then begin writeln(-1); exit; end
  64. else Ds:=-Ds;
  65. end;
  66.  
  67. T:= ceil(tdog+(abs(dist-spostpall))/(abs(Ds-Bs)));
  68. end;
  69.  
  70. writeln(T);
  71. end.
Success #stdin #stdout 0s 5324KB
stdin
1 2 4
0 0 0
R
stdout
 5.0000000000000000E-001
1