add pat 1045.cpp, dynamic programming