//06.12.22
//Author:Guo R.H
// USTC
//找出一个数组中若干个数相乘等于另外一个数的组合
#include
#include
#define N 10
int a[N] = {2,3,5,7,8,9,12,14,15,30};
void main()
{
unsigned int t=0;
int b[N],s,i,j;
for(t=0;t<(unsigned int)pow(2,N);t++)
{
s = 1;
for(i=0;i b[i] = t>>i & 1;
for(i=0; i if(b[i])
s *= a[N-1-i];
for(j=0;j {
if(!b[j] && s == a[N-1-j])
{
for(i=0; i {
if(b[i] == 1)
printf("%d*",a[N-i-1]);
}
printf("\10=%d\n",a[N-1-j]);
}
}
}
}
阅读(1141) | 评论(0) | 转发(0) |