• + 1 comment

    As nayeemjoy59 states you can easily complete the squares to get:
    Now one may resolve for x (or y) and do a brute force check in the range 1..c.
    However there is another path, that may pay off for big c and d. The expression is of form:
    Here you think immediatly of gaussian integers:

    That is: you can get every combination of squares of X and Y by factoring K into (ordinary) primes, then this primes into their gaussian factors and take all combinations that give 2 conjugate complex factors.
    some details see here
    .