// use itertools::Itertools; const MOD_998: usize = 998; const MOD_998244353: usize = 998244353; fn main() { let (n, k) = input_tuple::(); let a = input_vec::(); let mut result = 0_usize; // println!("{:?}", combination(n, k)); // for combination in (0..n).combinations(k) { for combination in combination(n, k) { let mut s_998 = 0_usize; let mut s_998244353 = 0_usize; for i in combination { s_998 += a[i]; s_998 %= MOD_998; s_998244353 += a[i]; s_998244353 %= MOD_998244353; } if s_998244353 <= s_998 { result += 1; result %= MOD_998; } } println!("{}", result); } fn combination(n: usize, k: usize) -> Vec> { let mut result = Vec::new(); rec(n, k, 0, &mut Vec::new(), &mut result); result } fn rec(n: usize, k: usize, index: usize, candi: &mut Vec, result: &mut Vec>) { if index == n { let mut candi_2 = Vec::new(); for i in 0..n { if candi[i] { candi_2.push(i); } } if candi_2.len() == k { result.push(candi_2); } return; } candi.push(true); rec(n, k, index + 1, candi, result); candi.pop(); candi.push(false); rec(n, k, index + 1, candi, result); candi.pop(); } fn input_tuple() -> (T, T) where T: std::str::FromStr, ::Err: std::fmt::Debug, { let stdin = std::io::stdin(); let mut buf = String::new(); stdin.read_line(&mut buf).unwrap(); buf = buf.trim_end().to_owned(); let mut iter = buf.split_whitespace(); let n = iter.next().unwrap().parse().unwrap(); let m = iter.next().unwrap().parse().unwrap(); (n, m) } fn input_vec() -> Vec where T: std::str::FromStr, ::Err: std::fmt::Debug, { let stdin = std::io::stdin(); let mut buf = String::new(); stdin.read_line(&mut buf).unwrap(); buf = buf.trim_end().to_owned(); let iter = buf.split_whitespace(); let line = iter.map(|x| x.parse().unwrap()).collect(); line }