#P9212. 「蓬莱人形」
「蓬莱人形」
Background
Mokou, who never grows old and never dies, can she still be called a "human"?
A human who has gone beyond life and death is unbelievable in itself.
Problem Description
To prove what humans are capable of, you need to solve a problem.
Given a sequence . There are queries:
- Each time you are given a pair , a modulus , and an interval . Find how many satisfy .
Input Format
The first line contains two positive integers , representing the length of the sequence and the number of queries.
The second line contains positive integers , describing the sequence .
The next lines each contain five integers , describing one query.
Output Format
Output lines in total. On the -th line, output the answer to the -th query.
10 5
4 3 2 5 8 5 3 3 1 2
1 10 3 7 6
4 10 5 5 4
2 7 1 2 9
5 9 3 4 7
1 3 5 1 8
4
0
6
3
2
Hint
Sample Explanation
- For the first query, the indices of elements that satisfy the condition are .
- For the second query, no element satisfies the condition.
- For the third query, the indices of elements that satisfy the condition are .
- For the fourth query, the indices of elements that satisfy the condition are .
- For the fifth query, the indices of elements that satisfy the condition are .
Constraints and Notes
For all testdata, , , , .
Translated by ChatGPT 5