#P5398. [Ynoi2018] GOSICK

[Ynoi2018] GOSICK

Background


Yo... dolls?

“You finally came.”

“So slow, the reaper who comes with spring.”
Victo... rica?

You... doesn’t your hand hurt?

Your hand is all red.

“Urusai... pull yourself together.”

“If you give up here, then we will never talk again, Kujo!”

“We are going back together.”

“I told you before too, together...”

“The place where we part, isn’t here, right?”

“So slow, the reaper who comes with spring.”

Don’t be mad, I was in a real hurry too.

Did you receive the letter?

“Yeah, because the address was written very carefully.”

“Using the fountain of wisdom, we finally arrived here.”

No matter how the world changes,

After this time, we will never be separated again.

Problem 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