modulo problem

http://www.codechef.com/SEPT14/problems/FLOORI4 I have tried the problem and got the logic to bt modulo is creating problem plz help

here i take modulo at each step of calculation still getting WA
my solution 1
http://www.codechef.com/viewsolution/4845720

please help