Update exgcd.cc
This commit is contained in:
parent
be147b16ee
commit
70f5673363
|
@ -50,6 +50,7 @@ namespace Exgcd {
|
||||||
|
|
||||||
// find the minimal non-negative integral solution of `ax = b (mod n)`
|
// find the minimal non-negative integral solution of `ax = b (mod n)`
|
||||||
optional<ll> congruential(ll a, ll b, ll n) {
|
optional<ll> congruential(ll a, ll b, ll n) {
|
||||||
|
if (a < 0 && a != LLONG_MIN && b != LLONG_MIN) a = -a, b = -b;
|
||||||
auto sol = diophantine(a, n, b);
|
auto sol = diophantine(a, n, b);
|
||||||
if (sol == nullopt) {
|
if (sol == nullopt) {
|
||||||
return nullopt;
|
return nullopt;
|
||||||
|
|
Loading…
Reference in New Issue