def egg_drop(n: int, k: int) -> int:
    """
    What is the minimum number of trials we need to drop eggs to determine which floors of a building are safe for
    dropping eggs, given n eggs and k floors?
    :param n: number of eggs
    :param k: number of floors
    :return: the minimum number of trials

    >>> egg_drop(1, 5)
    5
    >>> egg_drop(2,36)
    8
    """
    # Base cases.
    # If we have one egg, we need to try each floor.
    if n == 1:
        return k
    # If we have one floor, we need to try it.
    if k == 1 or k == 0:
        return k

    # Drop an egg from floor x:
    # 1. If it breaks, then we know the floor is <= x, and we have n-1 eggs left to do it, so E(n-1, x).
    # 2. If it doesn't break, then we know the floor is > x (which means k-x floors to try( and we have n eggs left
    #    to do it, so E(n, k-x).
    return 1 + min([max(egg_drop(n-1, x-1), egg_drop(n, k-x)) for x in range(1,k+1)])