#include #include #include int get_weigth(std::vector &weights, std::vector &curr_set) { int res = 0; for (int i = 0; i < weights.size(); ++i) if (curr_set[i]) res += weights[i]; return res; } int main() { int gangsters, capacity; std::cin >> gangsters >> capacity; std::vector weights; int t; for (int i = 0; i < gangsters; ++i) { std::cin >> t; weights.push_back(t); } std::vector> result(gangsters, std::vector(gangsters, 0)); for (int i = 1; i < gangsters; ++i) { std::vector curr_set(gangsters, false); for (int j = 0; j <= i; ++j) curr_set[gangsters - j] = true; do { // for (int j = 0; j < curr_set.size(); j++) // std::cout << curr_set[j]; // std::cout << std::endl; int curr_weigth = get_weigth(weights, curr_set); if(curr_weigth > capacity) continue; for (int j = 0; j < gangsters; ++j) { if (!curr_set[j]) { if (curr_weigth <= capacity && capacity < curr_weigth + weights[j]) { result[i][j] = (result[i][j] + 1) % 167772161; } } } } while (std::next_permutation(curr_set.begin(), curr_set.end())); } for(int i =0 ; i < gangsters;++i) { for(int j = 1; j< gangsters;++j) std::cout << result[j][i] << " "; std::cout << std::endl; } return 0; }