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:这题是裸的多重背包,同时纪念poj200题!!

Posted by zhepeng123 at 2016-11-22 19:11:48 on Problem 1014
In Reply To:这题是裸的多重背包,同时纪念poj200题!! Posted by:chubuxiao2015 at 2016-05-12 15:29:28
> 代码福利送上
> #include<stdio.h>
> #include<cstring>
> #include<algorithm>
> using namespace std;
> int i,j,k,t,sum,num;
> int a[1000];
> bool f[500000];
> int main()
> {
>     while(1){sum=num=0;
>         for(i=1;i<=6;i++){
>             scanf("%d",&k);
>             sum+=k*i;
>             j=1;
>             while(k>=j)a[++num]=j*i,k-=j,j*=2;
>             if(k)a[++num]=k*i;
>         }if(!sum)break;
>         printf("Collection #%d:\n",++t);
>         if(sum%2==1){printf("Can't be divided.\n\n");continue;}
>         memset(f,0,sizeof(f));
>         f[0]=1;
>         for(i=1;i<=num;i++)
>             for(j=sum;j>=a[i];j--)
>                 if(f[j-a[i]])f[j]=1;
>         if(f[sum/2])printf("Can be divided.\n\n");
>             else printf("Can't be divided.\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