using System.Collections.Generic; using System.Linq; using System; class Perm { public static void Swap(ref T x, ref T y) { T tmp = x; x = y; y = tmp; } public static bool NextPermutation(T[] array, int index, int length, Comparison comp) { if (length <= 1) return false; for (int i = length - 1; i > 0; i--) { int k = i - 1; if (comp(array[k], array[i]) < 0) { int j = Array.FindLastIndex(array, delegate (T x) { return comp(array[k], x) < 0; }); Swap(ref array[k], ref array[j]); Array.Reverse(array, i, length - i); return true; } } Array.Reverse(array, index, length); return false; } public static bool NextPermutation(T[] array) where T : IComparable { return NextPermutation(array, 0, array.Length, Comparer.Default.Compare); } } public class Hello { public static int MOD = 998244353; static void Main() { string[] line = Console.ReadLine().Trim().Split(' '); var n = int.Parse(line[0]); var k = int.Parse(line[1]); line = Console.ReadLine().Trim().Split(' '); var a = Array.ConvertAll(line, int.Parse); getAns(n, k, a); } static bool calc(int n, int[] a, int[] b) { var s998 = 0L; var sMOD = 0L; for (int i = 0; i < n; i++) { if (b[i] == 0) { s998 += a[i]; sMOD += a[i]; s998 %= 998; sMOD %= MOD; } } return sMOD <= s998; } static void getAns(int n, int k, int[] a) { var c = 0L; var b = Enumerable.Repeat(1, n).ToArray(); for (int i = 0; i < k; i++) b[i] = 0; do { if (calc(n,a, b)) c++; } while (Perm.NextPermutation(b)); Console.WriteLine(c %= 998); } }