Check for each divisor , if it is not divisible by any perfect square , simply return it as the answer .
for ( auto d : s ) { int divi = 0 ; for ( int j = 0 ; j < vec . size ( ) && vec [ j ] <= d ; j ++ ) { if ( d % vec [ j ] == 0 ) { divi = 1 ; break ; } } if ( ! divi ) return d ; } }