Positive and negative solutions of a class of nonlocal problems