dp [ i ] [ j ] represents true if sum j can be reachable by choosing i numbers
$ dp = array ( ) ; for ( $ i = 0 ; $ i < $ MAX + 1 ; $ i ++ ) { for ( $ j = 0 ; $ j < $ MAX * $ MAX + 1 ; $ j ++ ) $ dp [ $ i ] [ $ j ] = 0 ; } $ dp [ 0 ] [ 0 ] = 1 ;