#ifdef SENJAN #include #else #pragma GCC target("avx2") #pragma GCC optimize("O3") #pragma GCC optimize("unroll-loops") #define debug(...) #endif #include #include using namespace std; using namespace atcoder; using ll=long long; using ull=unsigned long long; using ld=long double; using graph=vector>; template using wgraph=vector>>; template using min_priority_queue=priority_queue,greater>; constexpr int INF32=INT_MAX/2; constexpr ll INF64=1LL<<60; constexpr ld PI=3.14159265358979323846; constexpr int dx[]={0,0,-1,1,-1,-1,1,1},dy[]={-1,1,0,0,-1,1,-1,1}; #define rep(i,s,n) for(ll i=(ll)(s);i<(ll)(n);i++) #define rrep(i,s,n) for(ll i=(ll)(s);i>=(ll)(n);i--) template inline bool chmax(T &a,T b){return a inline bool chmin(T &a,T b){return a>b?a=b,true:false;} void _main(); int main(){cin.tie(0)->sync_with_stdio(0);cout< bool next_combination(const T begin, const T end, int k){ const T sub = begin+k; if (begin==end || begin==sub || end==sub) return false; T src = sub; while(begin!=src){ src--; if((*src)<(*(end-1))){ T des=sub; while((*des)<=(*src)){ des++; } iter_swap(src, des); rotate(src+1, des+1, end); rotate(sub, sub+(end-des)-1, end); return true; } } rotate(begin, sub, end); return false; } void _main(){ int N, K; cin >> N >> K; vector A(N); rep(i,0,N) cin >> A[i]; vector id(N); iota(id.begin(), id.end(), 0); int ans{}; do{ ll s1{}, s2{}; rep(i,0,K){ s1 = (s1+A[id[i]]) % 998; s2 = (s2+A[id[i]]) % 998244353; } if(s1>=s2) ans = (ans+1) % 998; }while(next_combination(id.begin(), id.end(), K)); cout << ans << endl; }