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 |
你错的很明显啊In Reply To:这题我用背包做得..能找到得数据全没问题..一交上去就WA..TT..是不是有什么特殊数据我没考虑到啊? Posted by:Alexandra at 2007-12-14 19:55:35 > #include <stdio.h> > #include <string.h> > #define maxt 50000 > > int main() > { > freopen("p1014.in","r",stdin); > int i,j,k,n,sum; > int p[6+1],f[maxt]; > > n=0; > > while(1) > { > sum=0; > for(i=1;i<=6;i++) > { > scanf("%d",&p[i]); > p[i]%=12; > sum+=p[i]*i; > } > if(sum==0) > break; > > if(sum%2) > { > printf("Collection #%d:\nCan't be divided.\n\n",++n); > continue; > } > memset(f,0,sizeof(f)); > > f[0]=1; > for(i=1;i<=6;i++) > for(j=1;j<=p[i];j++) > for(k=sum/2;k>=i*j;k--) > f[k]=f[k] || f[k-i*j]; > if(f[sum/2]) > printf("Collection #%d:\nCan be divided.\n\n",++n); > else printf("Collection #%d:\nCan't be divided.\n\n",++n); > } > > return 0; > } 大哥你的程序错误很明显么 p[i]%=12; if(sum==0) break; 哪里有你这么判断退出的 如果输入数据是12 12 12 12 12 12 那你的程序会把这组数据当作全是0处理 就跳出了 所以你会WA Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator