아직 만들고 있는 페이지입니다.

이 페이지는 아직 만드는 중입니다. 보이는 내용은 바뀔 수 있습니다.

Trapezoid Counting

시간 제한30초메모리 제한1024 MB

요약
길이가 같은 막대도 서로 다른 것으로 세고 직사각형은 제외할 때, 주어진 막대 중 네 개를 골라 등변사다리꼴을 만드는 경우의 수를 센다.
난이도

보통10점 중 7점

유형
조합론, 수학, 정렬, 투 포인터
정답자
아직 제출이 없습니다

문제

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, T. T test cases follow; each consists of two lines. The first line consists of one integer N, the number of sticks. The second line consists of N integers; the i-th of these, Li, represents the length of the i-th stick.

출력

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

제한

  • 1 ≤ T ≤ 100.
  • 1 ≤ Li ≤ 109.

힌트

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.

예제1

  1. 예제 1

    입력
    4
    5
    2 3 3 4 3
    4
    1 5 3 1
    4
    2 2 3 3
    9
    3 4 1 4 2 5 3 1 3
    
    예상 출력
    Case #1: 5
    Case #2: 0
    Case #3: 0
    Case #4: 73