很笨的穷举法
//coins:2,3,5,7的个数,partition:分法
bool partitionCoin(int coins[],int partition[]){
int totalMoney = 2*coins[0]+3*coins[1]+5*coins[2]+7*coins[3];
if(totalMoney%2) return false;
int eachMoney = totalMoney>>1;
int c2,c3,c5,c7,cur;
for(c2=0;c2<=coins[0];c2++){
for(c3=0;c3<=coins[1];c3++){
for(c5=0;c5<=coins[2];c5++){
for(c7=0;c7<=coins[3];c7++){
cur = 2*c2+3*c3+5*c5+7*c7;
if(cur==eachMoney){
partition[0] = c2;
partition[1] = c3;
partition[2] = c5;
partition[3] = c7;
return true;
}else if(cur>eachMoney){
break;
}
}
}
}
}
return false;
}