摘要:
给出M个不同的数,每个数有无穷多个。从中选N个组成环,问最大公约数为1的方案有多少种。 上一题是这题的基础,不同的是每个数可以选多个,tot[i]表示m个数中i的倍数有多少个,那么用构成长度为l最大公约数为i的倍数的方案有tot[i]^l种,之后再用容斥求一下最大公约数为1的方案即可。 另外要考虑循环同构,套一个Burnside就行了,坑的就是N是10007倍数的情况,WA了N次。。要将MOD*n。。 1 #include <stdio.h> 2 #include <string.h> 3 #include <algorithm> 4 #define MAX 阅读全文
posted @ 2012-10-31 21:05
Burn_E
阅读(343)
评论(0)
推荐(0)
摘要:
在10^4方内选4个数,这4个数的最大公约数是1,求方案数。 先求出所有这样的数x=p1*p2*p3..*pn,pi是不同的素数,并且d(x)=n。然后容斥原理即可 ans=C(n,4)+∑C(x,4)*(-1)^d(x)。 1 #include <stdio.h> 2 #include <string.h> 3 #include <algorithm> 4 #define MAXN 10005 5 using namespace std; 6 typedef long long LL; 7 int flg[MAXN], x[MAXN], maxx; 8 L 阅读全文
posted @ 2012-10-31 16:50
Burn_E
阅读(252)
评论(0)
推荐(1)
摘要:
给一个集合S,问S有多少个子集满足子集中的数乘积是完全平方组。 一个数是完全平方数当且仅当它所有的质因数都有偶数个,所以只要看这个集合中所有数的质因数是否是偶数个即可。和开灯方案数问题类似,矩阵中X[i][j]=1表示第j个数的第i个质因数(2,3,5,7...)有奇数个,等于0表示有偶数个。然后列出XOR方程组然后算有几个自由基即可。 1 #include <stdio.h> 2 #include <string.h> 3 #include <algorithm> 4 using namespace std; 5 typedef long long LL; 阅读全文
posted @ 2012-10-31 15:39
Burn_E
阅读(367)
评论(0)
推荐(0)
摘要:
求从1开始,在一个有向图中经过某条边次数的期望。 E[p]=sigma(E[t]/deg[t]),t为能到p的点的集合,deg[t]为t的度数。对于起点要额外加1,因为第一次肯定会被运行一次。 高斯消元看的Rujia的代码,注意对无解的判断。 1 #include <string.h> 2 #include <stdio.h> 3 #include <vector> 4 #include <math.h> 5 #define MAXN 105 6 using namespace std; 7 const double eps = 1e-9; 8 阅读全文
posted @ 2012-10-31 01:00
Burn_E
阅读(272)
评论(0)
推荐(0)
浙公网安备 33010602011771号