题目:https://www.lydsy.com/JudgeOnline/problem.php?id=3195 看到数据范围就应该想到状压呢... 题解(原来是这样):https://www.cnblogs.com/LadyLex/p/7252789.html 代码如下: #include<iostream> #include<cstdio> #include<cstring> using namespace std; typedef long long ll; in…
Written with StackEdit. Description 小宇从历史书上了解到一个古老的文明.这个文明在各个方面高度发达,交通方面也不例外.考古学家已经知道,这个文明在全盛时期有\(n\)座城市,编号为\(1..n\).\(m\)条道路连接在这些城市之间,每条道路将两个城市连接起来,使得两地的居民可以方便地来往.一对城市之间可能存在多条道路. 据史料记载,这个文明的交通网络满足两个奇怪的特征.首先,这个文明崇拜数字\(K\),所以对于任何一条道路,设它连接的两个城市分别为\(u\)…
题目链接:http://poj.org/problem?id=3254 Time Limit: 2000MS Memory Limit: 65536K Description Farmer John has purchased a lush new rectangular pasture composed of M by N (1 ≤ M ≤ 12; 1 ≤ N ≤ 12) square parcels. He wants to grow some yummy corn for the cows…
正难则反,设g[s]为集合s不一定联通的方案数,这个很好求,把边数+1乘起来即可,f[s]为s一定联通的方案数 f考虑容斥,就是g[s]-Σf[nw]*g[s^nw],nw是s的子集,这样就减掉了不联通的情况 这个枚举子集的方法还挺巧的-- #include<iostream> #include<cstdio> using namespace std; const int N=20,mod=1000000007; int n,c[N][N],a[N],tot,f[100005],g…