摘要: 以下是我按照下方代码重新写了一遍之后的代码: #include <bits/stdc++.h> using namespace std; const int maxn = 1e5 + 5; const double alpha = 0.7; // 平衡因子 int root, idx, val[ma 阅读全文
posted @ 2026-07-05 20:19 quanjun 阅读(4) 评论(0) 推荐(0)
摘要: 题目链接:https://www.luogu.com.cn/problem/P3690 解题思路来自 《算法竞赛》这本书 (注:书中代码有些许bug,这里没有~) 代码参考自 算法竞赛书本中的代码,即 ecnerwaIa大佬的博客 示例程序: #include <bits/stdc++.h> usi 阅读全文
posted @ 2026-06-05 11:35 quanjun 阅读(6) 评论(0) 推荐(0)
摘要: 1. 我常常追忆过去。 出现在 P11831 [省选联考 2025] 追忆 的题目背景中。 阅读全文
posted @ 2026-05-28 20:37 quanjun 阅读(11) 评论(0) 推荐(0)
摘要: 题目链接:https://www.luogu.com.cn/problem/P2865 题目大意:求严格次短路。 解题思路: 先 spfa 跑一遍反图(由于是无向图,所以反图和原图其实是一样的图),得到估计函数的确定精确值。 然后 A* 跑一遍,即可。 示例程序: #include <bits/st 阅读全文
posted @ 2026-05-27 14:23 quanjun 阅读(11) 评论(0) 推荐(0)
摘要: 题目链接:https://codeforces.com/problemset/problem/896/C 解题思路:完全来自 oi.wiki 示例程序: #include <bits/stdc++.h> using namespace std; using ll = long long; const 阅读全文
posted @ 2026-05-25 14:06 quanjun 阅读(21) 评论(0) 推荐(0)
摘要: 题目链接:https://www.luogu.com.cn/problem/P4777 解题思路:完全来自 oi.wiki 注意:中间过程有一步可能会超 long long,得开 int128(代码第 \(39\) 行,因为这里有三个数相乘了) 示例程序: #include <bits/stdc++ 阅读全文
posted @ 2026-05-25 11:00 quanjun 阅读(3) 评论(0) 推荐(0)
摘要: 题目链接:https://www.luogu.com.cn/problem/P3193 解题思路: 建立完 KMP 的 nxt 数组之后(其实也可以建状态机,但是 \(m \le 20\) 所以建 状态机 并不是必要的),构造一个转移矩阵。然后矩阵乘法优化,就能够得到答案了。 #include <b 阅读全文
posted @ 2026-05-21 20:53 quanjun 阅读(11) 评论(0) 推荐(0)
摘要: 题目链接:https://www.luogu.com.cn/problem/P4345 解题思路: 示例程序: #include <bits/stdc++.h> using namespace std; using ll = long long; const ll p = 2333; ll c[p+ 阅读全文
posted @ 2026-05-21 16:53 quanjun 阅读(7) 评论(0) 推荐(0)
摘要: 参考链接:https://oi.wiki/math/number-theory/lucas/#exlucas-算法 解题思路: 扩展卢卡斯定理(Extended Lucas Theorem, exLucas),用于在模数 \(p\) 不一定是质数 的情况下,求组合数 \(C_n^m \pmod p\ 阅读全文
posted @ 2026-05-20 18:57 quanjun 阅读(18) 评论(0) 推荐(0)
摘要: 题目链接:https://www.luogu.com.cn/problem/U687409 解题思路: 求解 \((n!)_p \bmod p^a\) 的高效核心算法是递归分块法(常用于扩展卢卡斯定理 ExLucas)。 当 \(p^a\) 较小时(如 \(p^a \le 10^7\)),该算法可以 阅读全文
posted @ 2026-05-20 17:32 quanjun 阅读(11) 评论(0) 推荐(0)