The solution of the equation. Count (x, y)

I have problems with my math:

Suppose we have a function: F (x, y) = P; And my question is: what is the most efficient way to calculate the appropriate (x, y) graphs for this function? This means that I do not need coordinates, but I need a number . P is in the range: [0; 10 ^ 14]. "x" and "y" are integers. Is this solved with bruteforce or are there some advanced tricks (math / programming language (C, C ++)) to solve this problem quickly enough?

To be more specific, the function: x * y - ((x + y) / 2) + 1.

+3
source share
2 answers

x*y - ((x+y)/2) + 1 == Pequivalent to (2x-1)(2y-1) == (4P-3).

, 4P-3. C ++, , , . [: , A*B == C, , , (-A)*(-B) == C ].

C ++, , , , 4 * 10^14. int , long long.

+10

.

, , , . , , , , F<P, F>P, - F P.

( , , , , F '= FP), . . , !

, .

+2

All Articles