#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 . Each query gives an interval .
Count the number of ordered pairs such that and is a multiple of .
Input Format
The first line contains two integers .
The second line contains integers, representing the sequence .
Then follow lines, each containing two integers , 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 of the data, , .
Translated by ChatGPT 5