摘要: #include<stdio.h>#include<string.h>#include<stdlib.h>#include<math.h>#include<algorithm>using namespace std;int a[10010];struct T{ int sum; int head;}d[10010];int main(){ int n; while(scanf("%d",&n),n) { int head=-1; int i; bool flag=false; for(i=0;i<n; 阅读全文
posted @ 2012-08-09 22:10 willzhang 阅读(174) 评论(0) 推荐(0) 编辑
摘要: DP真心难。。。。不过这题还是比较简单的,状态转移为d[j]=d[j]>d[j-value[i-1]]*probi[i-1]?d[j]:d[j-value[i-1]]*probi[i-1];d[j]表示抢到j元的时候不被抓的最大概率#include<stdio.h>#include<stdlib.h>#include<math.h>#include<algorithm>#include<string.h>using namespace std;int sum;//能获得的最大值double Floor;int value[110 阅读全文
posted @ 2012-08-09 20:50 willzhang 阅读(215) 评论(0) 推荐(0) 编辑
摘要: 完全背包问题,并且要求恰好装满背包且求的是最小值#include<stdio.h>#include<string.h>#include<stdlib.h>#include<math.h>#include<algorithm>#define MAX 9999999999using namespace std;int sumweight;//int weight[550];int value[550];int N;//硬币种类数目__int64 d[10010];int main(){ int total; scanf("%d& 阅读全文
posted @ 2012-08-09 09:47 willzhang 阅读(157) 评论(0) 推荐(0) 编辑