Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
哪位帮我看看哪里错了?#include <stdio.h> #include <string.h> #define setz(x) memset(x,0,sizeof(x)) int main() { int x[10],b[11],f[1001]; int M,T,t,n,best,best_i,i,j,k; freopen("in","r",stdin); freopen("out","w",stdout); while (1==scanf("%d",&M) && M) { scanf("%d",&T); best=0; best_i=0; for (t=1;t<=T;t++) { scanf("%d",&n); for (i=0;i<n;i++) scanf("%d",x+i); setz(f); f[0]=true; for (i=0;i<M;i++) for (k=1000;k>=0;k--) for (j=0;j<n;j++) if (k-x[j]>=0 && f[k-x[j]]) f[k]=true; for (i=0;f[i] && i<=1000;i++) ; i--; if (i>best) { best=i; best_i=t; b[0]=n; for (i=0;i<n;i++) b[i+1]=x[i]; } } printf("max coverage = %d :",best); for (i=1;i<=b[0];i++) printf("% d",b[i]); printf("\n"); } return 0; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator