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

Re:这题我用背包做得..能找到得数据全没问题..一交上去就WA..TT..是不是有什么特殊数据我没考虑到啊?

Posted by wenqing at 2008-12-17 16:04:46 on Problem 1014
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;
> }

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