We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
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
.
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Count Solutions
You are viewing a single comment's thread. Return to all comments →
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
.