Do You Know Your ABCs?
Time limit1sMemory limit512 MB
Given 4 to 7 distinct integers, count how many triples (A,B,C) with A<=B<=C have every given number among A, B, C and their pairwise and total sums.
- Level
Medium6 of 10
- Topics
- Brute force, Math, Implementation, Hash map
- Solved
- No attempts yet
Problem
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
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
For each test case, output the number of triples that are consistent with the numbers Elsie presented.
Hint
For , the five possible triples are as follows: