Geometric Progression

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

요약
최대 백만 개의 정수가 엄격히 증가하는 수열로 주어질 때 i < j < k이고 a_i * a_k = a_j^2인 세 쌍의 개수를 센다. 값이 서로 다르다는 조건이 핵심이며, 중간항의 제곱 조건은 소인수분해로 다시 쓸 수 있다.
난이도

보통10점 중 7점

유형
정수론, 수학, 해시맵
정답자
아직 제출이 없습니다

문제

bobo loves geometric progressions! So he wants to know the number of geometric progressions of length 33 in a sequence a_1,a_2,…,a_na\_1, a\_2, \dots, a\_n.

That is to say, count the number of (i,j,k)(i, j, k) where i<j<ki < j < k and a_i⋅a_k=a_j2a\_{i} \cdot a\_{k} = a\_j^2.

입력

The first line contains an integer nn (1≤n≤10000001 \leq n \leq 1000000).

The second line contains nn integers a_1,a_2,…,a_na\_1, a\_2, \dots, a\_n (1≤a_1<a_2<⋯<a_n≤10000001 \leq a\_1 < a\_2 < \dots < a\_n \leq 1000000).

출력

A single integer denotes the number of geometric progressions.

예제2

  1. 예제 1

    입력
    3
    1 2 4
    
    예상 출력
    1
    
  2. 예제 2

    입력
    4
    1 2 4 8
    
    예상 출력
    2