-Added C++ implementaton. But it is not fast enough for SPOJ..