Simple C++ solutions for 50 and 56