Answers for ZOJ Problem in C++