Struggling with dp

Any one please help,try to solve the problem on uva oj link:Online Judge
unable to get the logic,any one please help me how to taclke this problem,also tell me how to get the base case?

Rod cutting problem


refer to CLRS Chapter Dynamic Programming.
Rod cutting.

above answer really refers to the Rod Cutting problem in Cormen Book. But for a little help i can say. Imagine that you had a rod of length only 1 then how you would have cut it. If rod had length 2 then how. If 3 then how. Simply you may understand how to do it. For help in code you may have look at this video. I also learned from this source how to code and the same person also has a channel on DP