Problem 017, C++