killer problem

uva

#1

how to solve [this][1] sum??
Are all query related problems solvable by segment tree??
[1]: http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=226&page=show_problem&problem=2998