GCD Pairs

시간 제한5초메모리 제한2048 MB

요약
길이 1e5 이하이고 각 원소가 1e12 이하인 배열에서, 최대공약수가 1보다 큰 제곱수로 나누어지지 않는 쌍의 개수를 센다.
난이도

어려움10점 중 8점

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

문제

In the Shape Galaxy, where all shapes are sentient beings, there is currently a feud between circles and squares. Circles want all pathways to be flat while squares argue that they should be evenly spaced inverted catenary shaped bumps. Because of this feud, circles have begun to dislike all square-biased numbers. A number ss is square-biased if it is divisible by x2x^2, for some integer x>1x > 1.

Mr. Circle has taken this feud to heart. He is given the assignment of calculating the greatest common divisor between all pairs of numbers in an array. He wants to go one step further and count the number of greatest common divisors that are not square biased.

입력

The first line of input contains a single integer, nn (1≤n≤105)(1 \le n \le 10^5), representing the length of the array of numbers.

The next nn lines contain the integers a_ia\_i (1≤a_i≤1012)(1 \le a\_i \le 10^{12}) which comprise the numbers in the array.

출력

Output a single integer, the number of pairs (i,j)(i, j) (1≤i<j≤n)(1 \le i < j \le n) such that gcd⁡(a_i,a_j)\gcd(a\_i, a\_j) is not square-biased.

예제1

  1. 예제 1

    입력
    6
    3
    4
    6
    12
    4
    1
    
    예상 출력
    12