C++ Code for HDU ACM