#include <iostream> #include <vector> #include <cstring> using namespace std; const int _max = 60; int c1[_max], c2[_max];//c1[i]:当前多项式x^i的系数 vector<int> cnt, v;//cnt[i]:第i个字母的个数 v[i]:第i个字母的权值 //请输出能找到的总价值(指数)<=50的单词数(系数) int main() { int t, i, j, k; cin >> t; while (t--) { memset(c1, 0, sizeof(c1)); memset(c2, 0, sizeof(c2)); cnt.clear(); v.clear(); for (i = 1; i <= 26; ++i) { int tmp; cin >> tmp; if (tmp != 0) { cnt.push_back(tmp); v.push_back(i); } } if (cnt.empty()) cout << 0 << endl; else { for (int i = 0; i <= 50 && i / v[0] <= cnt[0]; i += v[0]) c1[i] = 1; int len = (int) cnt.size(); for (i = 1; i < len; ++i) {//第i个表达式,len就是有效元素的个数 for (j = 0; j <= 50; ++j) {//我们只关心c1和c2运算结果指数<=50的 for (k = 0; k + j <= 50 && k / v[i] <= cnt[i]; k += v[i])//k是c2的指数 c2[k + j] += c1[j];//c1里的第j个元素与c2里指数为k的元素运算 } for (j = 0; j <= 50; ++j) { c1[j] = c2[j]; c2[j] = 0; } } int res = 0; for (int i = 1; i <= 50; ++i) res += c1[i]; cout << res << endl; } } return 0; }