Sponsored
Sponsored
Use these hints if you're stuck. Try solving on your own first.
Think if y cannot be small. You can solve a query in O(n/y), so if y is large enough, it won't be a problem.
If y is small, like less than B, you can preprocess the answers for all such ys in O(n * B), then answer each such query in O(1).
As you might have already guessed, the optimal value for B is ~sqrt(n).