上一页 1 ··· 27 28 29 30 31 32 33 34 35 ··· 47 下一页

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) 编辑

2012年5月26日

摘要: http://acm.hdu.edu.cn/showproblem.php?pid=1976水题View Code #include <stdio.h>#include <string.h>int main(){ int t; int a1,a2,a3; int b1,b2,b3; scanf("%d",&t); while(t--) { scanf("%d%d%d",&a1,&a2,&a3); scanf("%d%d%d",&b1,&b2,&b3); i 阅读全文
posted @ 2012-05-26 22:49 LegendaryAC 阅读(164) 评论(0) 推荐(0) 编辑
 
摘要: http://acm.hdu.edu.cn/showproblem.php?pid=1977很容易看出规律View Code #include <stdio.h>#include <string.h>int main(){ int t; __int64 n; scanf("%d",&t); while(t--) { scanf("%I64d",&n); printf("%I64d %I64d\n",n*n*n,(n+1)*(n+1)*(n+1)); } return 0;} 阅读全文
posted @ 2012-05-26 21:00 LegendaryAC 阅读(119) 评论(0) 推荐(0) 编辑

2012年5月25日

摘要: http://acm.hdu.edu.cn/showproblem.php?pid=3792n为负数,静态查询,用树状数组写,蛋疼可见一斑。打素数表的时候内层循环对i再加一个判断,是为了防止i*j因为溢出而恒真(引用自sx老祖)View Code #include <iostream>using namespace std ;const int MAX=100001;int prime[MAX],tree[MAX],num[MAX];int lowbit(int i){ return i&(-i);} void update(int x,int val){ for(int 阅读全文
posted @ 2012-05-25 14:37 LegendaryAC 阅读(315) 评论(0) 推荐(0) 编辑
 
摘要: http://acm.hdu.edu.cn/showproblem.php?pid=2368初中数学题,圆幂定理View Code #include <iostream>using namespace std ;int main(){ double r,w,l; int nCase=1; while(scanf("%lf",&r),r) { scanf("%lf%lf",&w,&l); if(r*r-(w/2)*(w/2)<(l/2)*(l/2)) printf("Pizza %d does not f 阅读全文
posted @ 2012-05-25 12:55 LegendaryAC 阅读(166) 评论(0) 推荐(0) 编辑
 
摘要: http://acm.hdu.edu.cn/showproblem.php?pid=1984字符串处理View Code #include <iostream>#include <string>using namespace std;int main(){ int t,n; char str[110]; scanf("%d",&t); for(int cas=1;cas<=t;cas++) { scanf("%d %s",&n,str); str[n-1]='\0'; printf(" 阅读全文
posted @ 2012-05-25 06:22 LegendaryAC 阅读(161) 评论(0) 推荐(0) 编辑
上一页 1 ··· 27 28 29 30 31 32 33 34 35 ··· 47 下一页