pku1014

#include < stdio.h >

#define MAXM7

int a[MAXM],sum,len; // ,aa[MAXM]

bool DFS( int nowLen, int sum2, int val) ... {
inti;
if(nowLen==len)...{
if(sum2==sum)
return1;
else
return0;
}

for(i=val;i<=6;i++)...{
if(a[i]>0)...{
a[i]
--;
if(DFS(nowLen+1,sum2+i,i))
return1;
a[i]
++;
}

}

return0;
}


int main()
... {
inti,j,n=0,n1,sum2,nowLen,val;
boolok=0;
n
=1;
scanf(
"%d%d%d%d%d%d",&a[1],&a[2],&a[3],&a[4],&a[5],&a[6]);
while(a[1]>0||a[2]>0||a[3]>0||a[4]>0||a[5]>0||a[6]>0)
...{
if(a[6]>5)...{
if(a[6]%2==0)
a[
6]=4;//aa[6]=
else
a[
6]=5;//=aa[6]
}


if(a[5]>6)...{
if(a[5]%2==0)
a[
5]=6;//=aa[5]
else
a[
5]=5;//=aa[5]
}


if(a[4]>5)...{
if(a[4]%2==0)
a[
4]=4;//aa[4]/
else
a[
4]=5;//=aa[4]
}


if(a[3]>5)...{
if(a[3]%2==0)
a[
3]=4;//aa[3]=
else
a[
3]=5;//aa[3]=
}


if(a[2]>4)...{
if(a[2]%2==0)
a[
2]=4;//aa[2]=
else
a[
2]=3;//aa[2]=
}


if(a[1]>7)...{
if(a[1]%2==0)
a[
1]=6;//aa[1]=
else
a[
1]=7;//aa[1]=
}


//for(i=1;i<=6;i++)aa[i]=a[i];
sum=0;
for(i=1;i<=6;i++)sum+=a[i]*i;

if(sum%2==1)...{
printf(
"Collection#%d: Can'tbedivided. ",n);
n
++;
scanf(
"%d%d%d%d%d%d",&a[1],&a[2],&a[3],&a[4],&a[5],&a[6]);
continue;
}


sum
/=2;j=1;
n1
=0;
for(i=1;i<=6;i++)...{
n1
+=a[i];
}


for(len=1;len<=n1/2;len++)...{
//for(i=1;i<=6;i++)a[i]=aa[i];//
nowLen=1;
ok
=0;
for(i=1;i<=6;i++)...{
if(a[i]>0)...{
a[i]
--;
sum2
=val=i;
if(DFS(nowLen,sum2,val))...{
ok
=1;
printf(
"Collection#%d: Canbedivided. ",n);
break;
}

a[i]
++;
}

}

if(ok)
break;
}

if(0==ok)
printf(
"Collection#%d: Can'tbedivided. ",n);

n
++;
scanf(
"%d%d%d%d%d%d",&a[1],&a[2],&a[3],&a[4],&a[5],&a[6]);
}

return0;
}


你可能感兴趣的:(J#)