Advertisement
believe_me

Untitled

Dec 19th, 2021
236
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Delphi 0.54 KB | None | 0 0
  1. function CountAnswer(Height, V1, V2: Integer): Integer;
  2.  
  3. var
  4.  
  5. CountOfStops: Integer;
  6.  
  7. Distance: Double;
  8.  
  9. IsNotReached: Boolean;
  10.  
  11. begin
  12.  
  13. if (V2 >= 4 * V1) and (V1 < Height) then
  14.  
  15. CountOfStops := -1
  16.  
  17. else
  18.  
  19. begin
  20.  
  21. Distance := 0;
  22.  
  23. CountOfStops := 0;
  24.  
  25. IsNotReached := True;
  26.  
  27. while IsNotReached do
  28.  
  29. begin
  30.  
  31. Distance := Distance + V1;
  32.  
  33. if Distance < Height then
  34.  
  35. begin
  36.  
  37. Distance := Distance - 0.25 * V2;
  38.  
  39. Inc(CountOfStops);
  40.  
  41. end
  42.  
  43. else
  44.  
  45. IsNotReached := False;
  46.  
  47. end;
  48.  
  49. end;
  50.  
  51. CountAnswer := CountOfStops;
  52.  
  53. end;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement