#P5629. 【AFOI-19】区间与除法
【AFOI-19】区间与除法
Description
Define the operation as: divide the current number by and take the floor.
SY now has “original numbers”. If a number can become an “original number” after performing the operation some number of times (including times), then this number can be wiped out by that “original number”. Note that “original numbers” will not be consumed.
Now SY asks you: for an interval , under the condition that you wipe out as many numbers as possible, what is the minimum number of “original numbers” needed?
Input Format
The first line contains numbers , representing the number of elements in the sequence , the number of “original numbers” SY has, the parameter of the operation, and the number of queries.
The second line contains the sequence , i.e., the numbers that need to be wiped out.
The third line contains “original numbers”.
The next lines each contain two numbers and , indicating the query interval .
Output Format
In the order of the queries, output one integer per line as the answer.
2 3 3 3
0 20
6 6 6
1 1
2 2
1 2
0
1
1
6 3 3 3
6 5 10 15 19 7
2 5 10
1 6
1 4
4 6
3
3
2
Hint
Sample Explanation:
Sample 1: can become after one operation (divide by and take the floor), but cannot become after any number of operations.
So for interval , at most numbers can be wiped out; under the condition of wiping out the maximum number of numbers, the minimum number of “original numbers” needed is . For intervals and , at most number can be wiped out; under that condition, the minimum number of “original numbers” needed is .
Sample 2: can wipe out , can wipe out , and can wipe out . So for intervals and , you can use all “original numbers” to wipe out everything. For interval , you can use to wipe out everything.
Constraints:
For of the testdata: .
For of the testdata: $n\le5\times 10^{5},m\leq60,2\leq d\leq10,q\le10^{6},0\le a_i,b_i< 2^{63}$.

Special property: the testdata is constructed.
Translated by ChatGPT 5
京公网安备 11011102002149号