Problem 014, C++