Problem 016, C++