| ||||||||||
| 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 | |||||||||
Re:这题我用背包做得..能找到得数据全没问题..一交上去就WA..TT..是不是有什么特殊数据我没考虑到啊?In Reply To:这题我用背包做得..能找到得数据全没问题..一交上去就WA..TT..是不是有什么特殊数据我没考虑到啊? Posted by:Alexandra at 2007-12-14 19:55:35 啊!我也用的背包,结果wa了!!!!!!
> #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;
> }
Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator