摘要: BSGS 题目:P3846-洛谷 题面 给定一个质数 \(p\),以及一个整数 \(g\),一个整数 \(a\),要求计算一个最小的非负整数 \(x\),满足 \[g^x \equiv a \pmod p \]做法 对于这种题目,可以用大步小步算法(Baby Step,Giant Step,简称 B 阅读全文
posted @ 2025-04-22 20:20 tyh_27 阅读(67) 评论(0) 推荐(0)
摘要: 卢卡斯定理(Lucas) 题目:P3807-洛谷 题面 给定整数 \(n,m,p\) 的值,求出 \(\binom{n+m}{n} \bmod p\) 的值,且保证 \(p\) 为质数。 做法 Step 0: 卢卡斯定理: \[\binom{n}{m}\equiv \binom{\lfloor{\f 阅读全文
posted @ 2025-04-16 17:01 tyh_27 阅读(28) 评论(0) 推荐(0)
摘要: 逆元 定义 若 \(ax\equiv1\pmod p\),且 \(a\) 与 \(p\) 互质,则称 \(x\) 为 \(a\) 的逆元,记为 \(a^{-1}\)。 所以对于求解 \(\frac{a}{b} \bmod p\),我们可以先求出 \(b\) 的逆元 \(b^{-1}\),在将 \(a 阅读全文
posted @ 2025-04-16 16:56 tyh_27 阅读(70) 评论(0) 推荐(0)
摘要: 数论 逆元 具体见这~ 欧拉函数 具体见这~ 扩展中国剩余定理(EXCRT) 具体见这~ 卢卡斯定理(Lucas) 具体见这~ BSGS 具体见这~ exBSGS 具体见这~ \[\large{\mathbb{END}} \] 阅读全文
posted @ 2025-04-15 21:28 tyh_27 阅读(27) 评论(0) 推荐(0)