摘要: 指数型生成函数公式(其中一个):指数阶一般求解的问题:已知有n种颜色的求,第1种X1个,第2种X2个,第3种X3个。。。求从中取m个的方案数(组合数)。公式中的ak/k!就是所求的组合数,ak为排列数。代码中:for(i = 1; i < n; i++) { for(j = 0; j <= m; ++j) { for(k = 0; k + j <= m && k <= val[i]; ++k) { c2[j + k] += c1[j]/Factorial(k); } ... 阅读全文
posted @ 2011-11-26 21:27 AC_Von 阅读(1265) 评论(0) 推荐(0) 编辑
摘要: 很裸的生成函数:My Code:#include <iostream>#include <cstring>#include <cstdio>using namespace std;const int N = 100;int c1[N], c2[N];int val[N];int main() { //freopen("data.in", "r", stdin); int i, j, k, t, ans; while(~scanf("%d", &t)) { while(t--) { for(i 阅读全文
posted @ 2011-11-26 20:04 AC_Von 阅读(202) 评论(0) 推荐(0) 编辑
摘要: 先打表,否则TLEMy Code:#include <iostream>#include <cstring>#include <cstdio>using namespace std;const int N = 32767;int c1[N+1], c2[N+1];int main() { //freopen("data.in", "r", stdin); int n, i, j, k; for(i = 0; i <= N; i++) { c1[i] = 1; c2[i] = 0; } for(i = 2; i & 阅读全文
posted @ 2011-11-26 18:55 AC_Von 阅读(233) 评论(0) 推荐(0) 编辑
摘要: /*用并查集做可以,不过总觉得别扭。明明是图论的题嘛。今天在师兄博客里看到这个 解法,用二分限定所取的边的权值。设最大与最小差为lim,最小为low。所以low <= weight <= low + lim;所以,用二分取到lim最小的一个。ps:限定low时需与熬用到hash,否则直接存m个weight会TLE。不能抵达终点输出-1,我晕,因为这个错了好几次。。。T_T*///My Code: 234+MS#include <iostream>#include <cstdio>#include <cstring>#include <set 阅读全文
posted @ 2011-11-26 17:53 AC_Von 阅读(176) 评论(0) 推荐(0) 编辑
摘要: 从组合数的定义可以知道。C(n, m) = C(n-1, m) + C(n-1, m-1);所以,根据这个公式可以递归的求得组合数,代码如下:long long C(int n, int m) { if(m == 0 || n == 0 || n == 1 || m == n) return 1; if(aug[n][m] != 0) return aug[n][m]; aug[n-1][m] = C(n-1, m); aug[n-1][m-1] = C(n-1, m-1); return aug[n-1][m] + aug[n-1][... 阅读全文
posted @ 2011-11-26 11:33 AC_Von 阅读(906) 评论(0) 推荐(0) 编辑
摘要: A题:看错题意了,WA了好几好几次。。。B题:闲的蛋疼多加了一个变量,nnd,我吃饱撑的!!C题:for循环的结束条件写错了,我靠!!!ps:各种错误,各种马虎,rating暴跌,T_T,悲摧啊。看来以后的适应一下晚上做题。。。 阅读全文
posted @ 2011-11-26 10:42 AC_Von 阅读(154) 评论(0) 推荐(0) 编辑