From c0ddbfc3c429db0d8ca03f066a6539d83a6b00f1 Mon Sep 17 00:00:00 2001 From: memset0 <34177126+memset0@users.noreply.github.com> Date: Tue, 24 Nov 2020 13:43:44 +0800 Subject: [PATCH] =?utf8?q?=E9=AB=98=E6=96=AF=E6=B6=88=E5=85=83=E4=B8=AD?= =?utf8?q?=E6=B1=82=E9=80=86=E5=85=83=E5=8F=AA=E9=9C=80=E8=A6=81O(k)?= =?utf8?q?=E6=AC=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- docs/graph/lgv.md | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/docs/graph/lgv.md b/docs/graph/lgv.md index d22ab497..e403add7 100644 --- a/docs/graph/lgv.md +++ b/docs/graph/lgv.md @@ -49,7 +49,7 @@ $$ 行列式可以使用高斯消元求。 -复杂度为 $O(n+k^2(k + \log p))$ ,其中 $\log p$ 是求逆元复杂度。 +复杂度为 $O(n+k(k^2 + \log p))$ ,其中 $\log p$ 是求逆元复杂度。 ??? note "参考代码" ```cpp @@ -108,9 +108,10 @@ $$ } } if (!m[i][i]) continue; + int inv = qpow(m[i][i], mod - 2); for (int j = i + 1; j <= k; ++j) { if (!m[j][i]) continue; - int mul = (ll)m[j][i] * qpow(m[i][i], mod - 2) % mod; + int mul = (ll)m[j][i] * inv % mod; for (int p = i; p <= k; ++p) { m[j][p] = (m[j][p] - (ll)m[i][p] * mul % mod + mod) % mod; } -- 2.11.0