From 70f56733638017ebe137d15bd7c95362bae7b8b4 Mon Sep 17 00:00:00 2001 From: Ariel Date: Mon, 19 Feb 2024 15:39:02 +0800 Subject: [PATCH] Update exgcd.cc --- number/exgcd.cc | 1 + 1 file changed, 1 insertion(+) diff --git a/number/exgcd.cc b/number/exgcd.cc index 7a02a14..c1d276d 100644 --- a/number/exgcd.cc +++ b/number/exgcd.cc @@ -50,6 +50,7 @@ namespace Exgcd { // find the minimal non-negative integral solution of `ax = b (mod n)` optional 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); if (sol == nullopt) { return nullopt;