Chef and Segments

I have used the idea of fenwick trees to solve this problem.
ans=tree[r]/tree[l-1];
I am getting wrong answer.Please help!!Thanks in advance.

problem-CHMOD Problem - CodeChef
my solutin link- CodeChef: Practical coding for everyone