摘要: 这道题很巧妙啊. 有两个性质: 1.一个图的最小生成树的每种边权数量是相等的. 2.有 1 得,如果任意一个最小生成树中边权为 $v$ 的边都断掉,$(x,y)$ 连通性在任意 MST 中都相等. 所以我们的做法就是先求出最小生成树,然后分别将每种边权 $v_{i}$ 从最小生成树中都断掉,得到若干 阅读全文
posted @ 2020-02-03 23:03 EM-LGH 阅读(155) 评论(0) 推荐(0) 编辑
摘要: 矩阵树定理求的是 $\sum_{E} \prod_{e \in E} w(e)$ 平时我们求的大多数是方案数,所以就默认那个 $w(e)$ 是 $1$. 而如果我们想求所有生成树权值之和的话就让那个 $w(e)$ 变成边权. 我们在设置最开始的那个 (度数-邻接)矩阵的时候度数矩阵中 $S1_{i, 阅读全文
posted @ 2020-02-03 21:29 EM-LGH 阅读(126) 评论(0) 推荐(0) 编辑
摘要: 有规律:$f[n]=3 \times f[n-1]-f[n-2]+2$. 由于没有模数,所以需要写一个高精度,这里直接套用的 FFT 板子. code: #include <cstdio> #include <cmath> #include <cstring> #include <algorithm 阅读全文
posted @ 2020-02-03 20:15 EM-LGH 阅读(131) 评论(0) 推荐(0) 编辑
摘要: 求生成树方案的话要用矩阵树定理,然后这个容斥就是常见套路了吧. code: #include <cstring> #include <cstdio> #include <vector> #include <algorithm> #define N 18 #define mod 1000000007 阅读全文
posted @ 2020-02-03 19:10 EM-LGH 阅读(117) 评论(0) 推荐(0) 编辑
摘要: code: #include <cstring> #include <cstdio> #include <algorithm> #define N 303 #define mod 1000000007 #define ll long long #define setIO(s) freopen(s". 阅读全文
posted @ 2020-02-03 17:57 EM-LGH 阅读(126) 评论(0) 推荐(0) 编辑
摘要: 这里的模数不是质数,所以需要用类似辗转相除的方式进行高斯消元. code: #include <cstdio> #include <algorithm> #define N 100 #define ll long long #define mod 1000000000 #define setIO(s 阅读全文
posted @ 2020-02-03 17:19 EM-LGH 阅读(125) 评论(0) 推荐(0) 编辑
摘要: 这里简单讲一下矩阵树定理: 我们分 3 种情况: 1. 给定一个无向图,求生成树个数. 2. 给定一个有向图,求以一个点为根的内向树个数. 3. 给定一个有向图,求以一个点为根的外向树个数. case1: 构造度数矩阵 $S1$,满足 $S1_{i,i}$ 等于 $i$ 点的度数(一条无向边当成两条 阅读全文
posted @ 2020-02-03 16:54 EM-LGH 阅读(189) 评论(0) 推荐(0) 编辑