一个比较简单的算法,效率不高,但应付楼主要求的数据量应该绰绰有余了
/**
* Written by [url=http://eastsun.javaeye.com]Eastsun[/url]
*/
#include<stdio.h>
#include<conio.h>
#define MAX 1000
#define SIZE 6
char flags[MAX+1];
int w[] ={1,2,3,5,10,20};
void check(int a[],int len){
int i,j;
if(len<=0) return;
check(a,len-1);
for(i=1;i<=a[len-1];i++)
for(j=MAX;j>=0;j--) if(flags[j]) flags[j+w[len-1]] =1;
}
int computer(int a[]){
int n,s=0;
flags[0] =1;
for(n=1;n<=MAX;n++) flags[n] =0;
check(a,SIZE);
for(n=1;n<=MAX;n++) s += flags[n];
return s;
}
int main(){
int a[SIZE],n;
printf(\"Input a1~a6:\");
for(n=0;n<SIZE;n++) scanf(\"%d\",&a[n]);
printf(\"Total: %d\",computer(a));
getch();
}