Initialize dp
for ( int i = 0 ; i < dp . GetLength ( 0 ) ; i ++ ) for ( int j = 0 ; j < dp . GetLength ( 1 ) ; j ++ ) for ( int k = 0 ; k < dp . GetLength ( 2 ) ; k ++ ) for ( int k1 = 0 ; k1 < dp . GetLength ( 3 ) ; k1 ++ ) dp [ i , j , k , k1 ] = - 1 ; return count ( 0 , 0 , 0 , 0 , num ) ; }