[Solution] Password Codeforces Solution | Solution Codeforces
Monocarp has forgotten the password to his mobile phone. The password consists of digits from to (note that it can start with the digit ).
Monocarp remembers that his password had exactly two different digits, and each of these digits appeared exactly two times in the password. Monocarp also remembers some digits which were definitely not used in the password.
You have to calculate the number of different sequences of digits that could be the password for Monocarp's mobile phone (i. e. these sequences should meet all constraints on Monocarp's password).
The first line contains a single integer () — the number of testcases.
The first line of each testcase contains a single integer () — the number of digits for which Monocarp remembers that they were not used in the password.
The second line contains different integers () representing the digits that were not used in the password. Note that the digits are given in ascending order.
For each testcase, print one integer — the number of different -digit sequences that meet the constraints.
In the first example, all possible passwords are: "3377", "3737", "3773", "7337", "7373", "7733".
No comments:
Post a Comment