modified rod_cutting.cpp