上一页 1 ··· 3 4 5 6 7 8 9 10 11 ··· 22 下一页
摘要: View Code //Catalan数//h[0]=h[1]=1//h[n]=sum(h[i]*h[n-i-1]) (n>i>=0)//递推关系:h[n]=C(2n,n)/(n+1);//1.括号化问题。//1.1 矩阵链乘: P=a1×a2×a3×……×an,依据乘法结合律,不改变其顺序,只用括号表示成对的乘积,试问有几种括号化的方案?(h(n)种)//2.出栈次序问题。//2.1 一个栈(无穷大)的进栈序列为1,2,3,..n,有多少个不同的出栈序列?//2.2 有2n个人排成一行进入剧场。入场费5元。其中只有n个人有一张5元钞票,另外 阅读全文
posted @ 2013-04-29 12:59 zhang1107 阅读(179) 评论(0) 推荐(0) 编辑
摘要: http://www.codeforces.com/problemset/problem/55/DView Code //dp[i][j][k] 表示长度为i的,对2520取模为j的,最小公倍数为k的数的个数,1~9最小公倍数只有48个,预处理出来。const int MM = 11111;typedef __int64 int64;#define mod 2520#define debug puts("wrong")int64 N,L,R;int num[MM],cnt;int64 dp[19][2520][50];int id[MM], g;void get_init( 阅读全文
posted @ 2013-04-29 12:45 zhang1107 阅读(186) 评论(0) 推荐(0) 编辑
摘要: map STLView Code //map<vector<int>,int>vis; 可以对一个list进行映射。//类似于map<map<int,int>,int>vis 之类的都是可以做到的,注意键值需要一一对应。//begin() 返回指向map头部的迭代器//clear() 删除所有元素//count() 返回指定元素出现的次数//empty() 如果map为空则返回true//end() 返回指向map末尾的迭代器//erase() 删除一个元素//find() 查找一个元素 //if(vis.find(x)!=vis.end())/ 阅读全文
posted @ 2013-04-29 10:49 zhang1107 阅读(129) 评论(0) 推荐(0) 编辑
摘要: http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemId=4013记忆化搜索,学到啦用map做映射不用担心数组开多大的问题,还有map<vector<int>,int>vis;可以对一个list进行映射,由于10^9以内的素数因子的组合很少,可以记忆化。View Code //记忆化搜索,学到啦用map做映射不用担心数组开多大的问题,还有map<vector<int>,int>vis;//可以对一个list进行映射,由于10^9以内的素数因子的组合很少,可以记忆化。const int M 阅读全文
posted @ 2013-04-29 10:34 zhang1107 阅读(257) 评论(0) 推荐(0) 编辑
摘要: [转]:http://hi.baidu.com/daizhy_acm/item/5c7e60dfcf33a1f8ca0c393eView Code 网络流题目集锦最大流 POJ 1273 Drainage Ditches POJ 1274 The Perfect Stall (二分图匹配) POJ 1698 Alice's Chance POJ 1459 Power Network POJ 2112 Optimal Milking (二分) POJ 2455 Secret Milking Machine (二分) POJ 3189 Steady Cow Assignment (枚举) 阅读全文
posted @ 2013-04-28 17:02 zhang1107 阅读(190) 评论(0) 推荐(0) 编辑
摘要: http://acm.hdu.edu.cn/showproblem.php?pid=3652View Code //dp[i][j][3] //表示前i个字符,余数为j //0 存在13,1前一个是1 ,2什么都没有const int MM = 1111;typedef __int64 int64;#define debug puts("wrong")#define mod 13int N,M;int num[MM], cnt;int dp[11][15][3]; //0 have 13 // 1 pre=1 // 2 noint dfs(int le,int r,int 阅读全文
posted @ 2013-04-27 16:42 zhang1107 阅读(130) 评论(0) 推荐(0) 编辑
摘要: http://acm.hdu.edu.cn/showproblem.php?pid=4389View Code const int MM = 1111;typedef __int64 int64;#define debug puts("wrong")int N,M;int num[MM], cnt;int dp[10][82][82][82];int dfs(int le,int sum,int mod,int r,bool less) { //less前一位是否取到最大e=less?num[le]:9 if(sum>mod) return 0; if(le==-1) 阅读全文
posted @ 2013-04-27 15:06 zhang1107 阅读(185) 评论(0) 推荐(0) 编辑
摘要: http://acm.hdu.edu.cn/showproblem.php?pid=3507View Code const int MM = 555555;#define debug puts("wrong")#define mod 100000000typedef __int64 int64;int N,M;int val[MM],sum[MM], dp[MM];int head,tail,sq[MM];/***************\斜率优化DP dp[i]=min(dp[j]+sqr(sum[i]-sum[j])+M | 1<=j<i)对于队尾a b , 阅读全文
posted @ 2013-04-27 12:43 zhang1107 阅读(183) 评论(0) 推荐(0) 编辑
摘要: http://acm.fzu.edu.cn/problem.php?pid=2107状态压缩DP,dp[i][j][k] 表示前i行j状态,有没有2*2普通放板的问题。深搜枚举的过程中记录当前和转移到的状态。View Code const int MM = 1111;typedef __int64 int64;#define debug puts("wrong")int N,M,L,ans,ss;char str[MM];int num[MM];int dp[10][32][3]; //0 no 1 yesvoid get_data() { int i,j,k; scanf 阅读全文
posted @ 2013-04-26 23:32 zhang1107 阅读(344) 评论(0) 推荐(0) 编辑
摘要: View Code struct Info{ int val,key; bool friend operator<(Info x,Info y) { return x.val>y.val; //定义比较,默认按照val大->小排序 }};multiset<int, greater<int> > sbt;//头文件:#include <set>//multiset<int> sbt; //默认小到大//multiset<int, greater<int> > sbt; //定义大到小//元素键值允许重复 O 阅读全文
posted @ 2013-04-26 16:26 zhang1107 阅读(211) 评论(0) 推荐(0) 编辑
上一页 1 ··· 3 4 5 6 7 8 9 10 11 ··· 22 下一页