description: You are given a binary string (i. e. a string consisting of characters 0 and/or 1) s of length n. You can perform the following operation with the string s at most once: choose a substring (a contiguous subsequence) of s having exactly k characters 1 in it, and shuffle it (reorder the characters in the substring as you wish).
  
  Calculate the number of different strings which can be obtained from s by performing this operation at most once.
  
  Input
  
  The first line contains two integers n and k (2 ≤ n ≤ 5000; 0 ≤ k ≤ n).
  
  The second line contains the string s of length n, consisting of characters 0 and/or 1.
  
  Output
  
  Print one integer — the number of different strings which can be obtained from s by performing the described operation at most once. Since the answer can be large, output it modulo 998244353.
  
  Examples
  
  Input
  
  
  7 2
  1100110
  
  
  Output
  
  
  16
  
  
  Input
  
  
  5 0
  10010
  
  
  Output
  
  
  1
  
  
  Input
  
  
  8 1
  10001000
  
  
  Output
  
  
  10
  
  
  Input
  
  
  10 8
  0010011000
  
  
  Output
  
  
  1
  
  Note
  
  Some strings you can obtain in the first example:
  
    * to obtain 0110110, you can take the substring from the 1-st character to the 4-th character, which is 1100, and reorder its characters to get 0110; 
    * to obtain 1111000, you can take the substring from the 3-rd character to the 7-th character, which is 00110, and reorder its characters to get 11000; 
    * to obtain 1100101, you can take the substring from the 5-th character to the 7-th character, which is 110, and reorder its characters to get 101. 
  
  
  
  In the second example, k = 0 so you can only choose the substrings consisting only of 0 characters. Reordering them doesn't change the string at all, so the only string you can obtain is 10010.
solution: #include <bits/stdc++.h>
  using namespace std;
  template <typename T>
  inline void read(T &x) {
    x = 0;
    T k = 1;
    char c = getchar();
    while (!isdigit(c)) {
      if (c == '-') k = -1;
      c = getchar();
    }
    while (isdigit(c)) {
      x = x * 10 + c - '0';
      c = getchar();
    }
    x *= k;
  }
  const int N = 5005;
  const int p = 998244353;
  char s[N];
  int nxt[N];
  int fac[N];
  int facinv[N];
  inline long long qpow(long long a, int b) {
    long long ans = 1;
    while (b) {
      if (b & 1) (ans *= a) %= p;
      (a *= a) %= p;
      b >>= 1;
    }
    return ans;
  }
  inline long long C(int n, int m) {
    return m > n ? 0 : (long long)fac[n] * facinv[m] % p * facinv[n - m] % p;
  }
  inline int add(int a, int b) { return (a += b) >= p ? a - p : a; }
  inline int sub(int a, int b) { return (a -= b) < 0 ? a + p : a; }
  int main() {
    int n, k;
    read(n), read(k);
    scanf("%s", s + 1);
    if (k == 0) {
      puts("1");
      return 0;
    }
    int cnt = 0;
    for (int i = 1; i <= n; ++i) {
      cnt += (s[i] == '1');
    }
    fac[0] = 1;
    for (int i = 1; i <= n; ++i) {
      fac[i] = (long long)fac[i - 1] * i % p;
    }
    facinv[n] = qpow(fac[n], p - 2);
    for (int i = n; i; --i) {
      facinv[i - 1] = (long long)facinv[i] * i % p;
    }
    if (cnt < k) {
      puts("1");
      return 0;
    }
    if (cnt == k) {
      printf("%lld\n", C(n, k));
      return 0;
    }
    cnt = 0;
    s[n + 1] = '1';
    int l = 1, r = 0;
    while (cnt < k) cnt += (s[++r] == '1');
    while (s[r + 1] != '1') ++r;
    int ans = C(r - l + 1, k);
    while (r < n) {
      int r0 = r;
      ++r;
      while (s[r + 1] != '1') ++r;
      while (s[l] != '1') ++l;
      ++l;
      ans = add(ans, sub(C(r - l + 1, k), C(r0 - l + 1, k - 1)));
    }
    printf("%d\n", ans);
    return 0;
  }
  