#P8962. 「WHOI-4」yadiw. Slua, gassp, lhtubs.

「WHOI-4」yadiw. Slua, gassp, lhtubs.

Background

If you know at least 3 of these things and you are not red — you are doing it wrong. Stop learning useless algorithms, go and solve some problems, learn how to use binary search.

Problem Description

Little F has a magical array aa. There are no duplicate elements in aa, and its length is nn. He sorted it using std::sort and believes it is ordered, so he is doing binary search in the following way. Obviously, whether it can be found only depends on the discretization result of the sequence, so you can directly treat aa as a permutation of 1n1 \sim n.

int search(int key) {
  int l = 1, r = n;
  while (l <= r) {
    int mid = (l + r) / 2;
    if (a[mid] < key)
      l = mid + 1;
    else if (a[mid] == key)
      return mid;
    else
      r = mid - 1;
  }
  return -1;
}

Unfortunately, in order to make him quit the “universal header” (wan neng tou), Little W wrote #define sort random_shuffle in bits/stdc++.h, which means that aa is actually a random permutation.

Now, for all nn in the range 11 to NN, and for all kk in the range 11 to nn, among all permutations of the array aa, how many of them can correctly find the kk-th smallest element keykey (i.e., the return value is not 1-1)? Since the answer may be too large, output it modulo the given modulus pp.

Input Format

One line with two positive integers p,Np, N.

Output Format

Output NN lines. Line nn contains nn positive integers, representing, among nn elements, the number of permutations for which searching for kk can succeed.

998244353 5

1
1 2
4 4 4
12 12 14 18
48 54 60 66 72

Hint

Constraints

This problem uses Subtask judging.

  • Subtask 1 (1010 pts): N=10N=10, p998244352p\ge998244352;
  • Subtask 2 (2525 pts): N=100N=100, p1009p\ge1009 and is prime;
  • Subtask 3 (2525 pts): N=400N=400, p1009p\ge1009 and is prime;
  • Subtask 4 (4040 pts): N=400N=400.

For all testdata, 10N40010\le N\le 400, 2p9982443532\le p\le998244353.

Translated by ChatGPT 5