dynamic programming example based on CLR 15.1
srm 576