Binary quadratic forms and sums of powersof integers