假设有x1个字母A, x2个字母B,… x26个字母Z,同时假设字母A的价值为1,字母B的价值为2,… 字母Z的价值为26。那么,对于给定的字母,可以找到多少价值<=50的单词呢?单词的价值就是组成一个单词的所有字母的价值之和,比如,单词ACM的价值是1+3+14=18,单词HDU的价值是8+4+21=33。(组成的单词与排列顺序无关,比如ACM与CMA认为是同一个单词)。
a i ≤ 20 a_i≤20 ai≤20
input
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
output
7
379297
solution
总 方 案 : ∏ i = 1 26 ( 1 + x 2 i + x 3 i + ⋅ ⋅ ⋅ + x i ∗ a i ) , 从 1 到 26 , 从 50 到 0 , 从 1 到 a i 遍 历 总方案:\prod\limits_{i=1}^{26}(1 + x^{2i} +x^{3i}+···+x^{i*a_i}),从1到26,从50到0,从1到a_i遍历 总方案:i=1∏26(1+x2i+x3i+⋅⋅⋅+xi∗ai),从1到26,从50到0,从1到ai遍历
code
//Siberian Squirrel
//#include<bits/stdc++.h>
#include<unordered_map>
#include<algorithm>
#include<iostream>
#include<cstring>
#include<cmath>
using namespace std;
typedef long long ll;
const double PI = acos(-1);
const double eps = 1e-7;
const int MOD = 3221225473;
const int N = 5e6 + 10;
const int UP = 50;
int f[60];
int limit;
inline ll solve(ll res = 0) {
memset(f, 0, sizeof f);
f[0] = 1;
for(int i = 1; i <= 26; ++ i) {
scanf("%d", &limit);
for(int j = UP; j >= 0; -- j) {
if(f[j] == 0) continue;
for(int k = 1; j + k * i <= UP && k <= limit; ++ k) {
f[j + k * i] += f[j];
}
}
}
for(int i = 1; i <= 50; ++ i)
res += f[i];
return res;
}
int main() {
#ifdef ACM_LOCAL
freopen("input", "r", stdin);
freopen("output", "w", stdout);
#endif
int o = 1;
scanf("%d", &o);
while(o --) {
printf("%lld\n", solve());
}
return 0;
}