P8962 "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.
Description
Little F has a magical array $a$. There are no duplicate elements in $a$, and its length is $n$. 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 $a$ as a permutation of $1 \sim n$.
```cpp
int search(int key) {
int l = 1, r = n;
while (l
Input Format
One line with two positive integers $p, N$.
Output Format
Output $N$ lines. Line $n$ contains $n$ positive integers, representing, among $n$ elements, the number of permutations for which searching for $k$ can succeed.
Explanation/Hint
**Constraints**
**This problem uses Subtask judging.**
- Subtask 1 ($10$ pts): $N=10$, $p\ge998244352$;
- Subtask 2 ($25$ pts): $N=100$, $p\ge1009$ **and is prime**;
- Subtask 3 ($25$ pts): $N=400$, $p\ge1009$ **and is prime**;
- Subtask 4 ($40$ pts): $N=400$.
For all testdata, $10\le N\le 400$, $2\le p\le998244353$.
Translated by ChatGPT 5