Logo
(追記) (追記ここまで)

23983번 - Product Triplets 서브태스크다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
40 초 (추가 시간 없음) 1024 MB124352527.473%

문제

Given N integers A1, A2, ..., AN, count the number of triplets (x, y, z) (with 1 ≤ x < y < z ≤ N) such that at least one of the following is true:

  • Ax = Ay × Az, and/or
  • Ay = Ax × Az, and/or
  • Az = Ax × Ay

입력

The first line of the input gives the number of test cases, T. T test cases follow. Each begins with one line containing an integer N: the number of integers in array A. The second line consists of N integers Ai; the i-th of these is the value of the i-th integer, as described above.

출력

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 triplets satisfying the condition given in the problem statement.

제한

  • 1 ≤ T ≤ 30.
  • 0 ≤ Ai ≤ 2 × 105, for all i.

Test Set 1 (5점)

  • 3 ≤ N ≤ 200.

Test Set 2 (12점)

  • 3 ≤ N ≤ 7000.

예제 입력 1

4
6
5 2 4 6 3 1
6
2 4 8 16 32 64
3
1 1 1
3
200000 200000 200000

예제 출력 1

Case #1: 1
Case #2: 6
Case #3: 1
Case #4: 0

힌트

In Sample Case #1, the only triplet satisfying the condition given in the problem statement is (2, 4, 5). The triplet is valid since the second, fourth, and fifth integers are 2, 6, and 3, and 2 × 3 = 6.

In Sample Case #2, the six triplets satisfying the condition given in the problem statement are: (1, 2, 3), (1, 3, 4), (1, 4, 5), (1, 5, 6), (2, 3, 5), (2, 4, 6).

In Sample Case #3, make sure you only count the triplet (1, 2, 3) once.

In Sample Case #4, there is no triplet satisfying the condition given in the problem statement since the product of any pair of integers in the array will not be in the array.

출처

Contest > Google > Kick Start > Google Kick Start 2018 > Round G A번

채점 및 기타 정보

  • 예제는 채점하지 않는다.
(追記) (追記ここまで)

출처

대학교 대회

  • 사업자 등록 번호: 541-88-00682
  • 대표자명: 최백준
  • 주소: 서울시 서초구 서초대로74길 29 서초파라곤 412호
  • 전화번호: 02-521-0487 (이메일로 연락 주세요)
  • 이메일: contacts@startlink.io
  • 통신판매신고번호: 제 2017-서울서초-2193 호

AltStyle によって変換されたページ (->オリジナル) /