笨-Archangel

导航

2012年5月3日

acm hdu 1087 Super Jumping! Jumping! Jumping!

摘要: #include<iostream>#include<cstdio>using namespace std;#include<cstring>int main(){ int N; int d[1000],num[1000]; while(cin>>N,N) { int i,j,sum=0; for(i=0;i<N;i++) cin>>num[i]; for(i=0;i<N;i++) { d[i]=num[i]; for(j=0;j<i;j++) ... 阅读全文

posted @ 2012-05-03 15:25 笨-Archangel 阅读(139) 评论(0) 推荐(0)

2012年4月11日

ACM HDU 1232 交通工程 并查集

摘要: #include<iostream>#include<cstdio>using namespace std;int city[1005];int sum;int find(int x){ int r=x; while(city[r]!=r) { r=city[r]; } return r;}void mege(int x,int y){ int fx,fy; fx=find(x); fy=find(y); if(fx!=fy) { if(fx>fy) city[fx]=fy; ... 阅读全文

posted @ 2012-04-11 16:46 笨-Archangel 阅读(117) 评论(0) 推荐(0)

2012年3月30日

hdu 3448Bag Problem

摘要: - -由于本人是极其水的水鸟,做此题是用DP过了样列可惜过不了OJ,于是狠下心来,上网抄了一段代码,改了一下,终于出现了本人的第一次用DFS做题(抄的还说自己的,不要面啊= =)同时也对代码做了注释和分析,希望水鸟们早日高飞~读题,K个物块,每个只能取一次(擦,我一开始以为无限取的。。。),求最接近M重量的背包。这题有两个限定量,还有一个就是背包只可以装N个物体,另外就是不能超过M值了。不废话了,剩下的靠你自己领悟DFS的写法了 1 #include<iostream> 2 using namespace std; 3 int n,m,k; //n代表可带数量物块数量 4 in.. 阅读全文

posted @ 2012-03-30 16:44 笨-Archangel 阅读(290) 评论(0) 推荐(0)

2012年3月28日

hdu 2602一个典型的背包问题

摘要: #include<cstdio>#include<cstring>int main(){ int T,N,V; scanf("%d",&T); int bg[1000],vol[1000],w[1000]; while(T--) { memset(bg,0,sizeof(bg)); scanf("%d%d",&N,&V); int i,j; for(i=1;i<=N;i++) scanf("%d",&w[i]); for(i=1;i<=N;i++) scanf(&qu 阅读全文

posted @ 2012-03-28 22:29 笨-Archangel 阅读(166) 评论(0) 推荐(0)