Help in solving this

I am getting WA on BROKEN problem of SPOJ

My code

http://ideone.com/zMzeF9

//