Codeforces Round 834 (Div. 3) |
---|
Finished |
A positive number $$$x$$$ of length $$$n$$$ in base $$$p$$$ ($$$2 \le p \le 10^9$$$) is written on the blackboard. The number $$$x$$$ is given as a sequence $$$a_1, a_2, \dots, a_n$$$ ($$$0 \le a_i < p$$$) — the digits of $$$x$$$ in order from left to right (most significant to least significant).
Dmitry is very fond of all the digits of this number system, so he wants to see each of them at least once.
In one operation, he can:
For example, $$$p=5$$$ and $$$x=234_5$$$.
Your task is to determine the minimum number of operations required to make all the digits from $$$0$$$ to $$$p-1$$$ appear on the board at least once.
The first line of the input contains a single integer $$$t$$$ ($$$1 \le t \le 2 \cdot 10^3$$$) — the number of test cases. The descriptions of the input test cases follow.
The first line of description of each test case contains two integers $$$n$$$ ($$$1 \le n \le 100$$$) and $$$p$$$ ($$$2 \le p \le 10^9$$$) — the length of the number and the base of the number system.
The second line of the description of each test case contains $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$0 \le a_i < p$$$) — digits of $$$x$$$ in number system with base $$$p$$$
It is guaranteed that the number $$$x$$$ does not contain leading zeros (that is, $$$a_1>0$$$).
For each test case print a single integer — the minimum number of operations required for Dmitry to get all the digits on the board from $$$0$$$ to $$$p-1$$$.
It can be shown that this always requires a finite number of operations.
112 31 24 21 1 1 16 61 2 3 4 5 05 21 0 1 0 13 101 2 35 10004 1 3 2 53 52 3 44 43 2 3 01 325 51 2 2 2 43 41 0 1
1 1 0 0 7 995 2 1 1 1 2
Name |
---|