from math import log2, log class DiffSolveTime: def __init__(self, p: int, q: int): self.__p = p self.__q = q def diff_solve_time(self, n: int | float) -> float: print(f"{n=}") return n ** 2 - self.__p - self.__q * n * log2(n) def diff_solve_time_derived(self, n: int | float) -> float: return n * 2 - self.__q * log2(n) - self.__q / log(2) def diff2_solve_time_derived(self, n: int | float) -> float: return 2 - self.__q / (n * log(2)) def get_inflection(self) -> float: return self.__q / (2*log(2)) def main(): P, Q = map(int, input().split()) solver = DiffSolveTime(P, Q) N = 1e2 while solver.diff_solve_time(N) < 0: N *= 10 while abs(solver.diff_solve_time(N)) > 1e-6: print(f"{N=}") N -= (solver.diff_solve_time(N)/solver.diff_solve_time_derived(N)) print(f"{N=}") print("loop end") print(N) if __name__ == "__main__": main()