上一页 1 ··· 4 5 6 7 8 9 10 11 下一页
摘要: 欧拉定理: \(a^{\varphi(m)} \equiv 1 \pmod m\) 推论 \(1\) :\(a^{\varphi(p-1)}\equiv 1 \pmod p\) ,其中 \(p\) 是质数(费马小定理)。 推论 \(2\) :若 \(a\perp m\) ,那么 \(a^{-1} \ 阅读全文
posted @ 2021-09-16 18:27 Themaxmaxmax 阅读(75) 评论(0) 推荐(0) 编辑
摘要: 题目链接 考虑将所有边权为 \(0\) 的边加入一张新图跑强连通分量缩点,处理出所有 \(0\) 环,缩点之后的图一定不存在 \(0\) 环。 用 \(\text{dijkstra}\) 跑出点 \(1\) 到其他所有点的最短路 \(dist[i]\)。 定义边 \((u,v,w)\) “在最短路中 阅读全文
posted @ 2021-09-16 15:35 Themaxmaxmax 阅读(57) 评论(0) 推荐(0) 编辑
摘要: 题目链接 考虑二分,每次 check 是否存在大于等于 \(m\) 条树上不交的链满足链长 \(\ge\) \(x\) 。 性质:对于以 \(x\) 为根的子树,至多存在一条一个端点在 \(x\) 的子树内,另一个端点在 \(x\) 子树外的路径。 那么意味着我们处理出以 \(x\) 为根的子树内的 阅读全文
posted @ 2021-09-15 19:01 Themaxmaxmax 阅读(33) 评论(0) 推荐(0) 编辑
摘要: 题目链接 欧拉定理: \(a^{\varphi(m)} \equiv 1 \pmod m\) 推论 \(1\) :\(a^{\varphi(p-1)}\equiv 1 \pmod p\) ,其中 \(p\) 是质数(费马小定理)。 推论 \(2\) :若 \(a\perp m\) ,那么 \(a^{ 阅读全文
posted @ 2021-09-15 13:30 Themaxmaxmax 阅读(33) 评论(0) 推荐(0) 编辑
摘要: inline int read(){ int s=0,f=1;char ch=getchar(); while(!isdigit(ch)) {if(ch=='-') f=-1;ch=getchar();} while(isdigit(ch)) s=s*10+ch-'0',ch=getchar(); 阅读全文
posted @ 2021-09-15 12:52 Themaxmaxmax 阅读(20) 评论(0) 推荐(0) 编辑
摘要: 非负权树贪心求树的直径:任意钦定一个根 \(r\),随便找一个距离 \(r\) 最远的点 \(u\) ,再以 \(u\) 为根找一个距离最远点 \(v\),\(u-v\) 即为直径。 证明考虑反证,按路径是否相交分类讨论。 1、直径两端点一定是两个叶子节点。 2、距离任意点最远的点一定是直径的一个端 阅读全文
posted @ 2021-09-12 12:15 Themaxmaxmax 阅读(82) 评论(0) 推荐(0) 编辑
摘要: 其中,满足分母大于 \(0\) 。 inline int ffloor(int x,int y) {return x>=0?x/y:-(-x-1)/y-1;} inline int fceil(int a,int b) { return ffloor(a-1,b) + 1; } 阅读全文
posted @ 2021-09-12 11:17 Themaxmaxmax 阅读(31) 评论(0) 推荐(0) 编辑
摘要: \(-\lceil r \rceil = \lfloor -r \rfloor,-\lfloor r \rfloor = \lceil -r \rceil\),\(\forall n\in Z,\lceil x + n\rceil = \lceil x \rceil + n,\lfloor x + 阅读全文
posted @ 2021-09-12 10:02 Themaxmaxmax 阅读(26) 评论(0) 推荐(0) 编辑
摘要: 题目链接 我们发现如果图中存在桥,那么代表着两个双连通分量之间有且只有一条路径,那么改成有向图后显然两个连通分量之间的边构不成环。 那么当且仅当无向图是边双连通图时,有解。 接下来考虑在求桥时的 \(\text{tarjan}\) 算法,\(\text{tarjan}\) 算法本质上是在 \(\te 阅读全文
posted @ 2021-09-11 20:08 Themaxmaxmax 阅读(46) 评论(0) 推荐(0) 编辑
摘要: void tarjan(int x,int from){ dfn[x] = ++sz; for (int i = head[x]; ~i; i = fail[i]) { if (i == (from ^ 1)) continue; int v = edge[i]; if (dfn[v]) { if 阅读全文
posted @ 2021-09-11 19:21 Themaxmaxmax 阅读(85) 评论(0) 推荐(0) 编辑
上一页 1 ··· 4 5 6 7 8 9 10 11 下一页