上一页 1 ··· 30 31 32 33 34 35 36 37 38 ··· 42 下一页
摘要: 01背包变形dp[ i ][ j ]:表示从前 i 家银行中抢劫某些家,得到 j 价值 而不被抓住的概率。类似01背包:dp[ j ]=max( dp[ j ],dp[ j - val[ i ] ]*( 1-w[ i ] ) ) );View Code 1 /* 2 01 背包 变异 3 dp[ i ]:偷i元的money不被抓的概率 4 */ 5 #include<stdio.h> 6 #include<stdlib.h> 7 #include<string.h> 8 #include<iostream> 9 #include<algor 阅读全文
posted @ 2012-12-13 23:23 xxx0624 阅读(231) 评论(0) 推荐(0) 编辑
摘要: 多重背包题意:价值为1,2,3,4,5,6. 分别有n[1],n[2],n[3],n[4],n[5],n[6]个。求能否找到满足价值刚好是所有的一半的方案。View Code 1 /* 2 多重背包 3 */ 4 #include<stdio.h> 5 #include<stdlib.h> 6 #include<string.h> 7 #include<iostream> 8 #include<algorithm> 9 #include<queue>10 #include<map>11 #include< 阅读全文
posted @ 2012-12-13 22:38 xxx0624 阅读(460) 评论(0) 推荐(0) 编辑
摘要: View Code 1 /* 2 dfs 从一个点出发最多能走多少步 3 用bfs较为麻烦 4 */ 5 #include<stdio.h> 6 #include<string.h> 7 #include<stdlib.h> 8 #include<algorithm> 9 #include<iostream>10 #include<queue>11 //#include<map>12 #include<math.h>13 using namespace std;14 typedef long lon 阅读全文
posted @ 2012-12-11 16:38 xxx0624 阅读(530) 评论(0) 推荐(0) 编辑
摘要: View Code 1 /* 2 模拟 简单 3 res[i][j]=mat[i][j]+d[sum]; 4 其中sum=mat[i][j]+i,j其他四个方向的值 5 */ 6 #include<stdio.h> 7 #include<string.h> 8 #include<stdlib.h> 9 #include<algorithm>10 #include<iostream>11 #include<queue>12 //#include<map>13 #include<math.h>14 us 阅读全文
posted @ 2012-12-11 13:40 xxx0624 阅读(274) 评论(0) 推荐(0) 编辑
摘要: 字典树关键在于怎样找出两个单词拼成的单词,可以用strncpy函数字典树标记了单词的结尾View Code 1 /* 2 字典树 3 */ 4 #include<stdio.h> 5 #include<stdlib.h> 6 #include<string.h> 7 #include<iostream> 8 #include<algorithm> 9 #include<queue>10 #include<map>11 #include<math.h>12 using namespace std;13 阅读全文
posted @ 2012-12-10 21:00 xxx0624 阅读(403) 评论(0) 推荐(0) 编辑
摘要: View Code 1 /* 2 贪心 排序 3 */ 4 #include<stdio.h> 5 #include<stdlib.h> 6 #include<string.h> 7 #include<iostream> 8 #include<algorithm> 9 #include<queue>10 #include<map>11 #include<math.h>12 using namespace std;13 const int maxn = 1505;14 const int inf = 阅读全文
posted @ 2012-12-10 19:37 xxx0624 阅读(741) 评论(8) 推荐(0) 编辑
摘要: View Code 1 /* 2 * 动态规划实现,算法复杂度O(n) 3 */ 4 int maxSubSequenceSum3(int a[], int len) 5 { 6 int i; 7 int curSum; /* 当前序列和 */ 8 int maxSum; /* 最大序列和 */ 9 10 /* 初始化当前序列和为0 */11 curSum = 0;12 13 /* 初始化最大子序列和为序列第一个元素 */14 maxSum = a[0];15 16 /* 开始循环求子序列和 */17 for (i = ... 阅读全文
posted @ 2012-12-09 15:19 xxx0624 阅读(169) 评论(0) 推荐(0) 编辑
摘要: View Code /*最小顶点覆盖:选出最少的点,这些点的关联的边都被覆盖最小顶点覆盖等于最大匹配*/#include#include#include#include#include#include#include#includeusing namespace std;const int maxn = 1505;const int inf = 0x7fffffff;struct node{ int u,val,next;}edge[ maxn<<2 ];int head[ maxn ],vis[ maxn ],fa[ maxn ];int cnt;void init(){ mem 阅读全文
posted @ 2012-12-09 14:33 xxx0624 阅读(865) 评论(0) 推荐(0) 编辑
摘要: View Code 1 /* 2 蜗牛从井底爬出来的时间,模拟 3 */ 4 #include<stdio.h> 5 #include<stdlib.h> 6 #include<string.h> 7 #include<iostream> 8 #include<algorithm> 9 #include<queue>10 #include<map>11 #include<math.h>12 using namespace std;13 const int maxn = 1005;14 const i 阅读全文
posted @ 2012-12-08 20:45 xxx0624 阅读(206) 评论(0) 推荐(0) 编辑
摘要: 字符串处理的简单题View Code 1 /* 2 字符串处理 简单 3 */ 4 #include<stdio.h> 5 #include<stdlib.h> 6 #include<string.h> 7 #include<iostream> 8 #include<algorithm> 9 #include<queue>10 #include<map>11 #include<math.h>12 using namespace std;13 const int maxn = 305;14 const 阅读全文
posted @ 2012-12-08 20:22 xxx0624 阅读(375) 评论(0) 推荐(0) 编辑
上一页 1 ··· 30 31 32 33 34 35 36 37 38 ··· 42 下一页