Finally Euler 54 question in C++!