Segment trees

Hello there!

I was asking myself, Is there any way to use implement segment trees in such way that the query depends on a parameter, not only on the pair of segments.

For example, find the sum of all segments from A to B such that they are divisible by K.

Do you recommend another algorithm.

Thanks for your answers