class IncreasingTimeout(object):
    __slots__ = ("_min", "_max", "_speed", "_min_i", "_max_i")

    @staticmethod
    def calculate(consecutive_count: int, minimum: float = 1.5, maximum: float = 60.0, speed: float = 0.4) -> float:
        return min(max(minimum, speed * consecutive_count ** 2), maximum)

    def __init__(self, minimum: float = 1.5, maximum: float = 60.0, speed: float = 0.4):
        assert minimum > 0.0
        assert maximum > minimum
        self._min = minimum
        self._max = maximum
        self._speed = speed
        i = 1
        while True:
            t = IncreasingTimeout.calculate(i, self._min, self._max, self._speed)
            if t > self._min:
                self._min_i = i - 1
                break
            i += 1
        while t < self._max:
            i += 1
            t = IncreasingTimeout.calculate(i, self._min, self._max, self._speed)
        self._max_i = i

    def get(self, consecutive_count: int) -> float:
        if consecutive_count < self._min_i:
            return self._min
        elif consecutive_count >= self._max_i:
            return self._max
        return IncreasingTimeout.calculate(consecutive_count, self._min, self._max, self._speed)
