#include using namespace std; vector global; int sum( list l) { int sum = 0; for(list::iterator it=l.begin(); it!=l.end() ; ++it) sum += *it; return sum; } void subset(vector &arr, unsigned long long int size, unsigned long long int left, unsigned long long int index, list &l) { if(left==0){ global.push_back(sum(l)); return; } for(unsigned long long int i=index; i> n >> k; vector vec; for (int i = 0; i < n; i++) { cin >> x; vec.push_back(x); } int output[n][n - 1] = {}; //for (int i = 1; i < n; i++) //{ for (int j = 0; j < n; j++) { vector vec1 = vec; vec1.erase(vec1.begin() + j); for (int i = 1; i < n; i++) { list lt; subset(vec1, vec1.size(), i, 0, lt); unsigned long long int res = 0; for (unsigned long long int i = 0; i < global.size(); i++) { if (global[i] <= k && global[i] + vec[j] > k) res++; } output[j][i - 1] = res % 167772161; global.clear(); } /*for (int z = 0; z < vecs.size(); z++) { for (int x = 0; x < vecs[z].size(); x++) cout << " " << vecs[z][x]; cout << endl; } cout << endl;*/ /*for (int i = 1; i < n; i++) { unsigned long long int res = 0; for (int ji = 0; ji < (int)vecs.size(); ji++) { if (vecs[ji].size() == i) { int sum = 0; for (int jj = 0; jj < (int)vecs[ji].size(); jj++) { sum += vecs[ji][jj]; } if (sum <= k && sum + vec[j] > k) res++; } } output[j][i - 1] = res % 167772161; }*/ } //} for (int i = 0; i < n; i++) { for (int j = 0; j < n - 1; j++) { if (j) cout << " "; cout << output[i][j]; } cout << endl; } return 0; }