1
0
Fork 0

Update exgcd.cc

This commit is contained in:
Ariel 2024-02-19 15:39:02 +08:00 committed by GitHub
parent be147b16ee
commit 70f5673363
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 1 additions and 0 deletions

View File

@ -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;