Count of Array
You love array, don't you? You are given two integer $N$ and $M$, along with an array $B$ of length $N$ containing **pairwise distinct** integers. You have to find the number of array $A$ of length $N$ satisfying the follow conditions: 1. $1 \leq A_i \leq M$. 2. $A_i \neq A_j$ for all $1 \le i \lt j \le N$. 3. $A_i \neq B_i$ for all $1 \le i \le N$. Since the answer can be very large, output it
HINT LADDERno hints yet
L1 Observation
L2 Technique
L3 Approach
L4 Pseudo-code
🔒
L5 Full solution
L5 unlocks only if you insist twice
solution.cppC++17
CodeSearch Tutor
Hints, not spoilers — it won’t hand over the full solution unless you insist.
Sign in to chat with the tutor and save your progress.
Sign in to start