Buggy python submission (verdict: Runtime Error):


def read_int():
    return int(input().strip())


def read_ints():
    return list(map(int, input().strip().split(' ')))


def solve():
    """
    h, n, w <= 3500
    4*h*n*w/(h*n+n*w+h*w) = N
    n*w+h*w = (n+h)*w = k*h*n  => k = (n+h)*w/(h*n)

    4hnw/(k+1)hn=4w/(k+1) = N
    """
    N = read_int()
    for w in range(1, 3501):
        if (4*w)%N == 0:
            k = (4*w)//N-1
            for n in range(1, 3501):
                if k*n-w > 0 and (n*w)%(k*n-w) == 0:
                    h = n*w//(k*n-w)
                    return h, n, w



if __name__ == '__main__':
    print(*solve())


Fixed submission:


def read_int():
    return int(input().strip())


def read_ints():
    return list(map(int, input().strip().split(' ')))


def solve():
    """
    h, n, w <= 3500
    4/N = 1/h+1/n+1/w
    1/h = 4/N-1/n-1/w = 4nw-Nw-Nn / Nnw
    """
    N = read_int()
    for w in range(1, 3501):
        for n in range(1, 3501):
            if (4*n*w-N*w-N*n) != 0 and (N*n*w)%(4*n*w-N*w-N*n) == 0:
                h = (N*n*w)//(4*n*w-N*w-N*n)
                if h > 0:
                    return h, n, w


if __name__ == '__main__':
    print(*solve())

Buggy python submission (verdict: Runtime Error):


def read_int():
    return int(input().strip())


def read_ints():
    return list(map(int, input().strip().split(' ')))


def solve():
    """
    h, n, w <= 3500
    4*h*n*w/(h*n+n*w+h*w) = N
    n*w+h*w = (n+h)*w = k*h*n  => k = (n+h)*w/(h*n)

    4hnw/(k+1)hn=4w/(k+1) = N
    """
    N = read_int()
    for w in range(1, 3501):
        if (4*w)%N == 0:
            k = (4*w)//N-1
            for n in range(1, 3501):
                if k*n-w > 0 and (n*w)%(k*n-w) == 0:
                    h = n*w//(k*n-w)
                    if h > 0:
                        return h, n, w


if __name__ == '__main__':
    print(*solve())


Fixed submission:


def read_int():
    return int(input().strip())


def read_ints():
    return list(map(int, input().strip().split(' ')))


def solve():
    """
    h, n, w <= 3500
    4/N = 1/h+1/n+1/w
    1/h = 4/N-1/n-1/w = 4nw-Nw-Nn / Nnw
    """
    N = read_int()
    for w in range(1, 3501):
        for n in range(1, 3501):
            if (4*n*w-N*w-N*n) != 0 and (N*n*w)%(4*n*w-N*w-N*n) == 0:
                h = (N*n*w)//(4*n*w-N*w-N*n)
                if h > 0:
                    return h, n, w


if __name__ == '__main__':
    print(*solve())

Buggy python submission (verdict: Runtime Error):


def read_int():
    return int(input().strip())


def read_ints():
    return list(map(int, input().strip().split(' ')))


def solve():
    """
    h, n, w <= 3500
    4*h*n*w/(h*n+n*w+h*w) = N
    n*w+h*w = (n+h)*w = k*h*n  => k = (n+h)*w/(h*n)

    4hnw/(k+1)hn=4w/(k+1) = N
    """
    N = read_int()
    for w in range(1, 3501):
        if (4*w)%N == 0:
            k = (4*w)//N-1
            for n in range(1, 3501):
                if k*n-w != 0 and (n*w)%(k*n-w) == 0:
                    h = n*w//(k*n-w)
                    if h > 0:
                        return h, n, w


if __name__ == '__main__':
    print(*solve())


Fixed submission:


def read_int():
    return int(input().strip())


def read_ints():
    return list(map(int, input().strip().split(' ')))


def solve():
    """
    h, n, w <= 3500
    4/N = 1/h+1/n+1/w
    1/h = 4/N-1/n-1/w = 4nw-Nw-Nn / Nnw
    """
    N = read_int()
    for w in range(1, 3501):
        for n in range(1, 3501):
            if (4*n*w-N*w-N*n) != 0 and (N*n*w)%(4*n*w-N*w-N*n) == 0:
                h = (N*n*w)//(4*n*w-N*w-N*n)
                if h > 0:
                    return h, n, w


if __name__ == '__main__':
    print(*solve())

Buggy python submission (verdict: Runtime Error):


def read_int():
    return int(input().strip())


def read_ints():
    return list(map(int, input().strip().split(' ')))


def solve():
    """
    h, n, w <= 3500
    4*h*n*w/(h*n+n*w+h*w) = N
    n*w+h*w = (n+h)*w = k*h*n  => k = (n+h)*w/(h*n)

    4hnw/(k+1)hn=4w/(k+1) = N
    """
    N = read_int()
    for w in range(1, 3501):
        if (4*w)%N == 0:
            k = (4*w)//N-1
            for n in range(1, 3501):
                if k*n-w != 0 and (n*w)%(k*n-w) == 0:
                    h = n*w//(k*n-w)
                    if h > 0:
                        print(f'{N}=4*{h}*{n}*{w}/({h}*{n}+{n}*{w}+{h}*{w})')
                        return h, n, w


if __name__ == '__main__':
    print(*solve())


Fixed submission:


def read_int():
    return int(input().strip())


def read_ints():
    return list(map(int, input().strip().split(' ')))


def solve():
    """
    h, n, w <= 3500
    4/N = 1/h+1/n+1/w
    1/h = 4/N-1/n-1/w = 4nw-Nw-Nn / Nnw
    """
    N = read_int()
    for w in range(1, 3501):
        for n in range(1, 3501):
            if (4*n*w-N*w-N*n) != 0 and (N*n*w)%(4*n*w-N*w-N*n) == 0:
                h = (N*n*w)//(4*n*w-N*w-N*n)
                if h > 0:
                    return h, n, w


if __name__ == '__main__':
    print(*solve())