Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function CountAnswer(Height, V1, V2: Integer): Integer;
- var
- CountOfStops: Integer;
- Distance: Double;
- IsNotReached: Boolean;
- begin
- if (V2 >= 4 * V1) and (V1 < Height) then
- CountOfStops := -1
- else
- begin
- Distance := 0;
- CountOfStops := 0;
- IsNotReached := True;
- while IsNotReached do
- begin
- Distance := Distance + V1;
- if Distance < Height then
- begin
- Distance := Distance - 0.25 * V2;
- Inc(CountOfStops);
- end
- else
- IsNotReached := False;
- end;
- end;
- CountAnswer := CountOfStops;
- end;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement