#USACOC2113B. Do You Know Your ABCs?
Do You Know Your ABCs?
Farmer John's cows have been holding a daily online gathering on the "mooZ" video meeting platform. For fun, they have invented a simple number game to play during the meeting to keep themselves entertained.
Elsie has three positive integers , , and (). These integers are supposed to be secret, so she will not directly reveal them to her sister Bessie. Instead, she tells Bessie distinct integers , claiming that each is one of , , , , , , or . However, Elsie may be lying; the integers might not correspond to any valid triple .
This is too hard for Bessie to wrap her head around, so it is up to you to determine the number of triples that are consistent with the numbers Elsie presented (possibly zero).
Each input file will contain test cases that should be solved independently.
Input Format
The first input line contains .
Each test case starts with , the number of integers Elsie gives to Bessie.
The second line of each test case contains distinct integers .
Output Format
For each test case, output the number of triples that are consistent with the numbers Elsie presented.
10
7
1 2 3 4 5 6 7
4
4 5 7 8
4
4 5 7 9
4
4 5 7 10
4
4 5 7 11
4
4 5 7 12
4
4 5 7 13
4
4 5 7 14
4
4 5 7 15
4
4 5 7 16
1
3
5
1
4
3
0
0
0
1
For , the five possible triples are as follows:
$$(2, 2, 5), (2, 3, 4), (2, 4, 5), (3, 4, 5), (4, 5, 7). $$
Scoring
- In test cases 1-4, all are at most .
- Test cases 5-6 satisfy .
- Test cases 7-15 satisfy no additional constraints.
Problem Credits
Benjamin Qi