how to improvise my code for FLOORI4? Getting TLE!

http://www.codechef.com/viewsolution/4858522
I am doing exactly what has been mentioned in the editorial…
Please help!

I improvised my code but this time I am getting WA! Please if anyone can tell what is wrong with it… Also, whwn i am giving n a value of 10^10 I am getting runtime error on ideone… Please help!
new code:
http://www.codechef.com/viewsolution/4858619