CF 1743A - Password
Monocarp has forgotten the password to his mobile phone. The password consists of 4 digits from 0 to 9 (note that it can start with the digit 0).
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 4 digits that could be the password for Monocarp's mobile phone (i. e. these sequences should meet all constraints on Monocarp's password).
Input
The first line contains a single integer t (1≤t≤200) — the number of testcases.
The first line of each testcase contains a single integer n (1≤n≤8) — the number of digits for which Monocarp remembers that they were not used in the password.
The second line contains n different integers a1,a2,…an (0≤ai≤9) representing the digits that were not used in the password. Note that the digits a1,a2,…,an are given in ascending order.
Output
For each testcase, print one integer — the number of different 4-digit sequences that meet the constraints.
------------------------------
Monocarp 忘记了手机密码。 密码由0到9的4位数字组成(注意可以以数字0开头)。
Monocarp 记得他的密码恰好有两个不同的数字,并且每个数字在密码中都出现了两次。 Monocarp 还记得一些密码中绝对没有使用的数字。
您必须计算可能成为 Monocarp 手机密码的不同 4 位数字序列的数量(即这些序列应满足 Monocarp 密码的所有限制)。
输入
第一行包含一个整数 t (1≤t≤200) — 测试用例的数量。
每个测试用例的第一行包含一个整数 n (1≤n≤8) — Monocarp 记住密码中未使用的位数。
第二行包含n个不同的整数a1,a2,…an (0≤ai≤9),代表密码中未使用的数字。 请注意,数字 a1,a2,…,an 按升序给出。
输出
对于每个测试用例,打印一个整数——满足约束的不同 4 位序列的数量。
---------------------
高中数学里面的排列组合,easy题目;
下面是代码: