johnny and beanstalk

can anybody explain the question and approach for this question…

got it…
http://www.codechef.com/viewsolution/7267090

//