getting tle in GSS1 of spoj

can anyone help me by telling why my code for gss1 is giving tle.

just made a few optimistations,using shift operators for multiplication,division and fast io.
Your solution:

thanks @vivek_1998299 but is there any other way to get ac without using these optimizations.

I dont think so,as ur logic is absolutely right.Even if u remove shift operators it’ll still get accepted.Majority of time is consumed due to I/O.U could try coding the iterative version.

when i removed shift operators i got tle.

Your solution without shift operator:

Ac in 0.15

U could remove the fast io,it’ll still get accepted (just use ‘\n’ instead of endl)

thanks didn’t knew that endl could make program that slow.