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

23518번 - Divisible Inversions 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
2 초 (추가 시간 없음) 512 MB51342281.481%

문제

Recently, Vasya learned how to calculate the number of inversions in a given permutation using Fenwick tree. However, Petya considers it an easy problem, so he decided to make a harder one. Petya asked Vasya to calculate the number of inversions such that the elements divide one another evenly. Formally, for the given permutation $(p_{1}, p_{2}, \ldots, p_{n}),ドル the task is to find the number of pairs of indices $(i, j)$ such that $i < j$ and $p_{i}$ is a multiple of $p_{j}$.

Help Vasya solve this problem.

입력

The first line contains an integer $n,ドル the length of the permutation (1ドル \le n \le 100,000円$). The second line contains $n$ space-separated integers $p_{i}$. It is guaranteed that the given integers form a permutation of integers from 1ドル$ to $n$.

출력

Print one integer: the number of divisible inversions in the given permutation.

제한

예제 입력 1

5
1 4 3 2 5

예제 출력 1

1

예제 입력 2

5
5 4 3 2 1

예제 출력 2

5

힌트

출처

Contest > Open Cup > 2018/2019 Season > Stage 17: Grand Prix of Baltic Sea H번

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

출처

대학교 대회

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

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