#include <stdio.h> #include <malloc.h> #define SUM 40 short find(short p[], short n, short s) { if (s == 0) return 1; if (n == 1) { if (p[0] != s) return 0; else return 1; } return (find(p, n - 1, s) + find(p, n - 1, s - p[n - 1])); } int main(void) { short n; //存储物体数目 short *p; //存储每个物体体积 scanf("%hd", &n); p = (short *)malloc(n * sizeof(short)); for (int i = 0; i < n; i++) { scanf("%hd", &p[i]); } printf("%hd\n", find(p, n, SUM)); return 0; }