atcoder#ABC230G. [ABC230G] GCD Permutation
[ABC230G] GCD Permutation
Score : points
Problem Statement
Given is a permutation of the integers from through .
Find the number of pairs of integers such that satisfying and . Here, for positive integers and , denotes the greatest common divisor of and .
Constraints
- is a permutation of .
- All values in input are integers.
Input
Input is given from Standard Input in the following format:
Output
Print the answer.
6
5 1 3 2 4 6
6
Six pairs , , , , , satisfy the condition, so should be printed.
12
1 2 3 4 5 6 7 8 9 10 11 12
32