#P5398. [Ynoi2018] GOSICK

[Ynoi2018] GOSICK

Description

Victo rica gives you a sequence aa. Each query gives an interval [l,r][l,r].

Count the number of ordered pairs (i,j)(i,j) such that li,jrl \leq i,j \leq r and aia_i is a multiple of aja_j.

Input Format

The first line contains two integers n,mn,m.

The second line contains nn integers, representing the sequence aa.

Then follow mm lines, each containing two integers l,rl,r, representing one query.

Output Format

For each query, output one line with one integer, representing the answer.

6 3
1 1 4 5 1 4
1 1
4 5
1 4

1
3
10

Hint

Idea: nzhtl1477, Solution: nzhtl1477, Code: nzhtl1477, Data: nzhtl1477.

Constraints: for 100%100\% of the data, 1n,m,ai5×1051 \leq n,m,a_i \leq 5 \times 10^5, 1lrn1 \leq l \leq r \leq n.

Translated by ChatGPT 5