标签:hdu2082
2 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 9 2 6 2 10 2 2 5 6 1 0 2 7 0 2 2 7 5 10 6 10 2 10 6 1 9
7 379297
#include <stdio.h> #include <string.h> #define maxn 30 #define maxc 52 int arr[maxn], c1[maxc], c2[maxc]; int main() { // freopen("stdin.txt", "r", stdin); int t, i, j, k; scanf("%d", &t); while(t--) { for(i = 1; i <= 26; ++i) scanf("%d", &arr[i]); for(i = 0; i <= 50; ++i) c1[i] = c2[i] = 0; for(i = 1; !arr[i]; ++i) ; for(j = 0; j <= arr[i] * i; j += i) c1[j] = 1; for(++i; i <= 26; ++i) { if(!arr[i]) continue; for(j = 0; j <= 50; ++j) for(k = 0; k <= arr[i] * i && j + k <= 50; k += i) c2[k+j] += c1[j]; for(j = 0; j <= 50; ++j) { c1[j] = c2[j]; c2[j] = 0; } } for(i = 2; i <= 50; ++i) c1[1] += c1[i]; printf("%d\n", c1[1]); } return 0; }
标签:hdu2082
原文地址:http://blog.csdn.net/chang_mu/article/details/40214079