anyone who solved this problem http://codeforces.net/problemset/problem/12/D , can please share his ideas.
i have read this blog http://codeforces.net/blog/entry/44775#comment-437643 , the explanation which is written by
@satyaki3794 , how will it fit in time limit ?