def unit_form(disc):
    """
    Return generated quadratic form with the given discriminant.
    """
    if disc & 3 == 0:
        a = 1
        b = 0
        c = disc // -4
    elif disc & 3 == 1:
        a = 1
        b = 1
        c = (disc - 1) // -4
    else:
        raise ValueError("discriminant is not 0 or 1 mod 4.")
    return (a, b, c)