PersonalCorpus 版 (精华区)
41360 2002-10-13 21:37:41 Accepted
1149 C++ 00:08.56 620K Big Guava
int main()
{
#ifndef ONLINE_JUDGE
freopen("c:\\0acm\\zju\\i1149","r",stdin);
freopen("c:\\0acm\\zju\\o1149","w",stdout);
#endif
int a[7],i,j,k,sum,t=0,l;
bool marka[120001],markb[120001];
while (1) {
scanf("%d%d%d%d%d%d\n",&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; else t++;
memset(marka,0,sizeof(marka));
marka[0]=true;
sum=0;
for (i=1;i<7;i++) if (a[i]>0) {
memset(markb,0,sizeof(markb));
for (k=0;k<=sum;k++) if (marka[k])
for (j=0;j<=a[i];j+=2) {
markb[k+(a[i]-j)*i]=true;
l=k-(a[i]-j)*i;
if (l<0) markb[-l]=true; else markb[l]=true;
}
sum+=i*a[i];
memcpy(marka,markb,sizeof(marka));
}
printf("Collection #%d:\n",t);
if (marka[0]) printf("Can be divided.\n\n");
else printf("Can't be divided.\n\n");
}
}
Powered by KBS BBS 2.0 (http://dev.kcn.cn)
页面执行时间:2.743毫秒