3453. Trapezoid Counting (Small)

单点时限: 2.0 sec

内存限制: 256 MB

In this problem, we will consider a trapezoid to be a convex quadrilateral with exactly one pair of parallel sides. If the lengths of the two non-parallel sides are equal, we say the trapezoid is isosceles.

You have some wooden sticks of various lengths, and you need to pick exactly four of them to form the four sides of an isosceles trapezoid. How many different sets of four sticks will allow this? Even if two sticks have the same length, they are considered to be different sticks. Sticks could not be bended and broke into parts.

输入格式

The first line of the input gives the number of test cases, . test cases follow; each consists of two lines. The first line consists of one integer , the number of sticks. The second line consists of integers; the -th of these, , represents the length of the -th stick.

  • Limits: .
  • Small dataset: .
  • Large dataset: .

输出格式

For each test case, output one line containing Case #x: y, where is the test case number (starting from 1), and is the number of different sets of four sticks that can form an isosceles trapezoid, as described above.

样例

Input
5
5
2 3 3 4 3
4
1 5 3 1
4
2 2 3 3
4
999999998 999999999 999999999 1000000000
9
3 4 1 4 2 5 3 1 3
Output
Case #1: 5
Case #2: 0
Case #3: 0
Case #4: 1
Case #5: 73

提示

In Sample Case #1, there are five ways to choose four out of the five given sticks, and any one of those five sets of four sticks can be used to form an isosceles trapezoid.

In Sample Case #2, note that the set {1, 1, 3, 5} cannot form an isosceles trapezoid, even though two of its sticks are of equal length.

In Sample Case #3, note that the set {2, 2, 3, 3} can form a rectangle, but in this problem, a rectangle is not considered to be an isosceles trapezoid.

11 人解决,13 人已尝试。

12 份提交通过,共有 29 份提交。

5.2 EMB 奖励。

创建: 2 年,1 月前.

修改: 2 年,1 月前.

最后提交: 1 年,9 月前.

来源: Kickstart 2017 Round E

题目标签