/* ***********************************************
Author :xryz
Email :[email protected]
Created Time :2015/7/16 8:29:33
File Name :C:\Users\Administrator\Desktop\0001.cpp
************************************************ */
#include <stdio.h>
#include <string.h>
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <string>
#include <math.h>
#include <stdlib.h>
#include <time.h>
using namespace std;
int sum,v,dp[50000];
void zeroonepack(int cost,int weight)
{
for(int i=v; i>=cost; i--)
{
dp[i]=max(dp[i],dp[i-cost]+weight);
}
}
void completepack(int cost ,int weight)
{
for(int i=cost; i<=v; i++)
{
dp[i]=max(dp[i],dp[i-cost]+weight);
}
}
void multiplepack(int cost ,int weight,int amount)
{
if(cost*amount>=v)
{
completepack(cost,weight);
}
else
{
int k=1;
while(k<amount)
{
zeroonepack(cost*k,weight*k);
amount-=k;
k*=2;
}
zeroonepack(cost*amount,weight*amount);
}
}
int main()
{
//freopen("in.txt","r",stdin);
//freopen("out.txt","w",stdout);
int _=0,a[10],i;
while(~scanf("%d%d%d%d%d%d",&a[1],&a[2],&a[3],&a[4],&a[5],&a[6]))
{
if(a[1]==0&&a[2]==0&&a[3]==0&&a[4]==0&&a[5]==0&&a[6]==0) break;
sum=0;
for(i=1; i<=6; i++)
sum+=i*a[i];
v=sum/2;
memset(dp,0,sizeof(dp));
for(i=1; i<=6; i++)
{
multiplepack(i,i,a[i]);
}
printf("Collection #%d:\n",++_);
if(sum==2*dp[v])
printf("Can be divided.\n\n");
else
printf("Can‘t be divided.\n\n");
}
return 0;
}
版权声明:本文为博主原创文章,未经博主允许不得转载。
时间: 2024-10-06 11:09:33