nested loop to find other two factors
for ( int i = v [ n ] . size ( ) - 1 ; i >= 0 ; i -- ) { for ( int j = v [ n ] . size ( ) - 1 ; j >= 0 ; j -- ) { if ( ( fac * 2 ) + ( v [ n ] [ j ] + v [ n ] [ i ] ) == n ) ans = max ( ans , fac * fac * v [ n ] [ j ] * v [ n ] [ i ] ) ; } } return ans ; } } } }