No cost for a single rope
if ( i == j ) dp [ i , j ] = 0 ; else { for ( int k = i ; k < j ; k ++ ) { dp [ i , j ] = Math . Min ( dp [ i , j ] , dp [ i , k ] + dp [ k + 1 , j ] + sum [ i , j ] ) ; } } } } return dp [ 0 , n - 1 ] ; }