摘要: 题目:http://acm.hdu.edu.cn/showproblem.php?pid=1203#include using namespace std;double dp[10010]={0};int ans;void ZeroOnPack(int cost,double weight,int V,double P){ for(int i=V;i>=cost;i--) { dp[i] = max(dp[i],dp[i-cost]*(1-weight)); if(dp[i]>=1-P&&ans>T; while(T--) { ... 阅读全文
posted @ 2013-09-21 21:50 Destino74 阅读(94) 评论(0) 推荐(0) 编辑
摘要: 题目:http://acm.hdu.edu.cn/showproblem.php?pid=2955逃脱机率 = 1 - 总的被捉机率#include using namespace std;double dp[10010]={0};int ans;void ZeroOnPack(int cost,double weight,int V,double P){ for(int i=V;i>=cost;i--) { dp[i] = max(dp[i],dp[i-cost]*(1-weight)); if(dp[i]>=1-P&&ans>T; while(... 阅读全文
posted @ 2013-09-21 21:50 Destino74 阅读(117) 评论(0) 推荐(0) 编辑
摘要: 题目:http://acm.hdu.edu.cn/showproblem.php?pid=2191#include using namespace std;int main(int argc, const char *argv[]){ int T; //freopen("input.txt","r",stdin); while(cin>>T) { while(T--) { int money,type; int dp[124]={0}; memset(dp,0,sizeof(d... 阅读全文
posted @ 2013-09-21 21:48 Destino74 阅读(167) 评论(0) 推荐(0) 编辑
摘要: 题目:http://acm.hdu.edu.cn/showproblem.php?pid=3033经典,分组背包,第一次做这类题,其实就是多加一重循环用于分组DP。#include using namespace std;int dp[15][10100];int brand[110],cost[110],val[110];int main(int argc, const char *argv[]){ int N,M,K; //freopen("input.txt","r",stdin); while(cin>>N>>M>& 阅读全文
posted @ 2013-09-21 21:45 Destino74 阅读(156) 评论(0) 推荐(0) 编辑
摘要: 题目:http://acm.hdu.edu.cn/showproblem.php?pid=1059多重背包,自己理解后,模板记在这了,背包九讲是好东西#include using namespace std;int dp[240480];void ZeroOnPack(int cost,int weight,int V){ for(int i=V;i>=cost;i--) { if(dp[i-cost]) dp[i]=1; }}void CompletePack(int cost,int weight,int V){ for(int ... 阅读全文
posted @ 2013-09-21 21:44 Destino74 阅读(152) 评论(0) 推荐(0) 编辑
摘要: 题目:http://acm.hdu.edu.cn/showproblem.php?pid=2571//#include #include using namespace std ;int dp[1000][1000]={0};int main(int argc, const char *argv[]){ //freopen("input.txt","r",stdin); int n,m; int T; cin>>T; while(T--) { cin>>n>>m; for (int i = 1; i >dp[i] 阅读全文
posted @ 2013-09-21 21:39 Destino74 阅读(157) 评论(0) 推荐(0) 编辑
摘要: 题目:http://acm.hdu.edu.cn/showproblem.php?pid=1176#include using namespace std;int max1(int a,int b,int c){ if(a>b) return a>c?a:c; else return b>c?b:c;}int dp[100005][11]={0};//dp[i][j]代表第i秒时第j个位置能得到的最大值int cook[100005][11]={0};int main(int argc, const char *argv[]){ //freopen("input.. 阅读全文
posted @ 2013-09-21 21:38 Destino74 阅读(152) 评论(0) 推荐(0) 编辑
摘要: 题目:http://acm.hdu.edu.cn/showproblem.php?pid=2546#include using namespace std;int dp[1010]={0};void ZeroOnePack(int cost,int weight,int V){ for(int i=V-5;i>=cost;i--) dp[i]=max(dp[i],dp[i-cost]+weight);}int main(int argc, const char *argv[]){ int n; //freopen("input.txt","r",s 阅读全文
posted @ 2013-09-21 21:21 Destino74 阅读(148) 评论(0) 推荐(0) 编辑
摘要: 题目:http://acm.hdu.edu.cn/showproblem.php?pid=1160#include #include using namespace std;struct DP{ int w; int s; int len; int index; int parent;};bool cmp(const DP&a,const DP&b){ if(a.w==b.w) return a.s>b.s; else return a.w>dp[l].w>>dp[l].s) { dp[l].index=l; ... 阅读全文
posted @ 2013-09-21 21:17 Destino74 阅读(162) 评论(0) 推荐(0) 编辑
摘要: 题目:http://acm.hdu.edu.cn/showproblem.php?pid=1058#include #include #include using namespace std;int main(int argc, const char *argv[]){ int p2,p3,p5,p7;//记录2,3,5,7 set dp; dp.insert(1); while(dp.size()::iterator i=dp.begin(); i!=dp.end(); ++i) { int t = *i; ... 阅读全文
posted @ 2013-09-21 21:17 Destino74 阅读(132) 评论(0) 推荐(0) 编辑
摘要: 题目:http://acm.hdu.edu.cn/showproblem.php?pid=1087#include #include int dp[1050],x[1050],num[1050];void main(){ int n,i,j,k,max; while(scanf("%d",&n)!=EOF&&n) { memset(dp,0,sizeof(dp)); memset(num,0,sizeof(num)); k=0; for(i=1;i0;j--) { if(num... 阅读全文
posted @ 2013-09-21 21:14 Destino74 阅读(77) 评论(0) 推荐(0) 编辑
摘要: 题目:http://acm.hdu.edu.cn/showproblem.php?pid=1003#include using namespace std;int b,e,n;int max_num(){ int res_max = -(1>t; suffeix_max = suffeix_max + t; if(suffeix_max>res_max) { res_max = suffeix_max; b = tb; e = j; } if(suffe... 阅读全文
posted @ 2013-09-21 21:00 Destino74 阅读(142) 评论(0) 推荐(0) 编辑
摘要: 题目:http://acm.hdu.edu.cn/showproblem.php?pid=1297同样递推,不过用了大数#include #include using namespace std;string add(const string &a,const string &b){ int dig = 0;//½øλ·û string a1,b1; if(a.size()>b.size()) { a1 = a; b1 = b; }else { a1 = b; b1 = a; } int ... 阅读全文
posted @ 2013-09-21 20:58 Destino74 阅读(141) 评论(0) 推荐(0) 编辑
摘要: 题目:http://acm.hdu.edu.cn/showproblem.php?pid=2045突然想起来,这种递推题都是可以用数学方法推出公式做出来的.>书上有讲.数学方法好牛叉啊..把系数解出来就AC了..#include #include using namespace std;int main(){ int n; while(cin>>n) { if(n==1) cout#include int main(void){ int i; __int64 d[51] = {0, 3, 6, 6}; for (i = 4; i < 51; i... 阅读全文
posted @ 2013-09-21 20:56 Destino74 阅读(143) 评论(0) 推荐(0) 编辑
摘要: 题目:http://acm.hdu.edu.cn/showproblem.php?pid=2190递推,找规律不难.#include using namespace std;int main(){ int T; __int64 d[31] = {0, 1, 3, 5}; for (int i = 4; i >T; for(int i=0;i>n; cout<<d[n]<<endl; } return 0;} 阅读全文
posted @ 2013-09-21 20:50 Destino74 阅读(160) 评论(0) 推荐(0) 编辑
摘要: 题目:http://acm.hdu.edu.cn/showproblem.php?pid=2050数学题,递推题,好吧,这种题我最不会了。看网上的分析A了,大概遇到相同的还是不会,数学题还是给队友吧#include int main(void){ int n, i; scanf("%d", &i); while (i-- && scanf("%d", &n)) printf("%d\n", 2*n*n-n+1); return 0;} 阅读全文
posted @ 2013-09-21 20:48 Destino74 阅读(114) 评论(0) 推荐(0) 编辑
摘要: 题目:http://acm.hdu.edu.cn/showproblem.php?pid=2018递推,每年生的牛 = 上一年的所有母牛数 + 4年前所有母牛数(因为每4年母牛长大,大母牛会生小母牛) f(n) = f(n-1) + f(n-3)#include using namespace std;int main(){ int f[56]= {0,1,2,3,4,6}; for(int i=6; i>n&&n) { cout<<f[n]<<endl; } return 0;} 阅读全文
posted @ 2013-09-21 20:44 Destino74 阅读(197) 评论(0) 推荐(0) 编辑
摘要: 题目:http://acm.hdu.edu.cn/showproblem.php?pid=2046递推题#include using namespace std;int main(){ int n; __int64 dp[51]={0,1,2,3}; for(int i=4;i>n) { cout<<dp[n]<<endl; } return 0;} 阅读全文
posted @ 2013-09-21 20:39 Destino74 阅读(133) 评论(0) 推荐(0) 编辑