#pragma GCC optimize("O3") #pragma GCC optimize("unroll-loops") #include #include #include int main() { int n, k, cnt = 0; std::cin >> n >> k; std::vector a(n); for(auto &el: a) { std::cin >> el; } std::vector> pat, ano; for(int i = 0; i < 1 << (n / 2); ++i) { std::vector x; for(int j = 0; j < n / 2; ++j) { if(i >> j & 1) { x.emplace_back(a[j]); } } if(std::ssize(x) == k) pat.emplace_back(x); /*if(std::ssize(x) == k) { const auto res = std::accumulate(x.begin(), x.end(), 0LL); if(res % 998 >= res % 998244353) { cnt++; cnt %= 998; } }//*/ } for(int i = 0; i < 1 << (n - n / 2); ++i) { std::vector x; for(int j = 0; j < n - n / 2; ++j) { if(i >> j & 1) { x.emplace_back(a[n / 2 + j]); } } if(std::ssize(x) == k) ano.emplace_back(x); /* { const auto res = std::accumulate(x.begin(), x.end(), 0LL); if(res % 998 >= res % 998244353) { cnt++; cnt %= 998; } }//*/ } for(const auto &l: pat) { for(const auto &r: ano) { auto v = l; v.insert(v.end(), r.cbegin(), r.cend()); if(std::ssize(v) == k) { const auto res = std::accumulate(v.begin(), v.end(), 0LL); if(res % 998 >= res % 998244353) { cnt++; cnt %= 998; } } } } std::cout << cnt << '\n'; }