上一页 1 2 3 4 5 6 7 ··· 66 下一页
摘要: 题目链接:https://www.luogu.com.cn/problem/P2865 题目大意:求严格次短路。 解题思路: 先 spfa 跑一遍反图(由于是无向图,所以反图和原图其实是一样的图),得到估计函数的确定精确值。 然后 A* 跑一遍,即可。 示例程序: #include <bits/st 阅读全文
posted @ 2026-05-27 14:23 quanjun 阅读(27) 评论(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 阅读(32) 评论(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 阅读(10) 评论(0) 推荐(0)
摘要: 题目链接:https://www.luogu.com.cn/problem/P3193 解题思路: 建立完 KMP 的 nxt 数组之后(其实也可以建状态机,但是 \(m \le 20\) 所以建 状态机 并不是必要的),构造一个转移矩阵。然后矩阵乘法优化,就能够得到答案了。 #include <b 阅读全文
posted @ 2026-05-21 20:53 quanjun 阅读(16) 评论(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 阅读(12) 评论(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 阅读(24) 评论(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 阅读(19) 评论(0) 推荐(0)
摘要: 题目链接:https://atcoder.jp/contests/abc280/tasks/abc280_d 解题思路: 首先对 \(K\) 进行质因数分解,然后二分 \(N\),判断 \(K\) 的每个质因数的次数是否都 \(\le n!\) 中包含的这个质因子的次数即可。 示例程序: #incl 阅读全文
posted @ 2026-05-20 14:40 quanjun 阅读(18) 评论(0) 推荐(0)
摘要: 参考链接:https://oi.wiki/math/number-theory/factorial/#legendre-公式 在正整数 \(n!\) 的质因数分解中,质数 \(p\) 的指数(即 \(n!\) 能被 \(p\) 整除的最高次数,记为 \(v_p(n!)\))可以通过以下公式计算: \ 阅读全文
posted @ 2026-05-20 09:59 quanjun 阅读(86) 评论(0) 推荐(0)
摘要: 解决本题的核心在于利用莫比乌斯反演或容斥原理,将“最大公约数(\(\gcd\))等于 1”的限制转化为“统计倍数个数”。 核心思路 直接统计 \(\gcd(a_i, a_j, a_k, a_l) = 1\) 的四元组非常困难,因此我们采用莫比乌斯反演进行转化: 根据莫比乌斯函数的性质:\(\sum_ 阅读全文
posted @ 2026-05-18 19:09 quanjun 阅读(29) 评论(0) 推荐(0)
上一页 1 2 3 4 5 6 7 ··· 66 下一页