2012年5月27日

摘要: http://acm.hdu.edu.cn/showproblem.php?pid=120301背包ps:做01背包经常不注意数组的大小,这题数组开小了又是各种waView Code #include <iostream>using namespace std ;double f[10001],w[1001];int c[1001];int main(){ int n,m; while(scanf("%d%d",&n,&m)) { if(n==0&&m==0)break; for(int i=1;i<=m;i++) scan 阅读全文
posted @ 2012-05-27 23:16 LegendaryAC 阅读(140) 评论(0) 推荐(0) 编辑
 
摘要: http://acm.hdu.edu.cn/showproblem.php?pid=254601背包,开始内层循环写成v>=0无限wa。。。一定要注意数组越界的问题、、、View Code #include <iostream>using namespace std ;int main(){ int n; while(scanf("%d",&n),n) { int w[1010]; int maxx=0; int flag; for(int i=1;i<=n;i++) { scanf(... 阅读全文
posted @ 2012-05-27 22:38 LegendaryAC 阅读(193) 评论(0) 推荐(0) 编辑
 
摘要: http://acm.hdu.edu.cn/showproblem.php?pid=1009无聊的贪心View Code #include <stdio.h>#include <stdlib.h>typedef struct L{ int j,k; double w;}L;L kk[1001];int cmp(const void*a,const void*b){ L*c=(L*)a; L*d=(L*)b; return d->w > c->w ? 1 : -1 ;}int main(){ int m,n; while(scanf("%d%d 阅读全文
posted @ 2012-05-27 16:45 LegendaryAC 阅读(124) 评论(0) 推荐(0) 编辑
 
摘要: http://acm.hdu.edu.cn/showproblem.php?pid=2539无聊题,可能会有人名开头小写的数据,所以一定要倒着找no,我这种写法是中间出了点故障,导致写的很麻烦,不足取View Code #include <iostream>#include <string>using namespace std ;int main(){ int n; while(scanf("%d%*c",&n),n) { int flag1[10],flag2[10]; char str[101]; int ans1=0,ans2... 阅读全文
posted @ 2012-05-27 16:17 LegendaryAC 阅读(281) 评论(0) 推荐(0) 编辑
 
摘要: http://acm.hdu.edu.cn/showproblem.php?pid=1982字符串处理View Code #include <iostream>#include <string>using namespace std ;char str[27]={"ABCDEFGHIJKLMNOPQRSTUVWXYZ"};int main(){ int t; scanf("%d%*c",&t); while(t--) { string s; cin >> s ; for(int i=0;i<s.lengt 阅读全文
posted @ 2012-05-27 10:04 LegendaryAC 阅读(184) 评论(0) 推荐(0) 编辑