def compare(n, x, target):
    """
    Sum(x, n) = 1+x+x^2+...+x^n = ( x^(n+1) - 1 ) / ( x -1 )
    return 0 if Sum(x, n) == target
    return 1 if Sum(x, n) > target
    return -1 if Sum(x, n) < target
    """
    x_1 = x - 1
    x_n_plus_1 = x ** (n+1) - 1
    prod = target * x_1
    if prod == x_n_plus_1:
        return 0
    if prod < x_n_plus_1:
        return 1
    return -1