Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

哪位帮我看看哪里错了?

Posted by ufx at 2004-10-12 14:20:29 on Problem 1882
#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:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator