We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
Algorithm
ll gcd(ll a, ll b, ll & x, ll & y) { if (!a) { x = 0, y = 1; return b; } ll x1, y1; ll d = gcd(b % a, a, x1, y1); x = y1 - (b / a) * x1; y = x1; return d; } bool diophantine(ll a, ll b, ll c, ll & x0, ll & y0, ll & g) { g = gcd(abs(a), abs(b), x0, y0); if (c % g) return false; x0 *= c / g; y0 *= c / g; if (a < 0) x0 = -x0; if (b < 0) y0 = -y0; return true; }