Create a table to store the results of subproblems . One extra row and column are used for simplicity ( Number of dice is directly used as row index and sum is directly used as column index ) . The entries in 0 th row and 0 th column are never used .
long [ ] [ ] table = new long [ n + 1 ] [ x + 1 ] ;