解法
荷物を置く向き全てについて全探索をします。
コード
typedef vector<int> VI; #define FOR( v, c ) for ( auto &v : c ) #define ALL( c ) (c).begin(), (c).end() int check( VI box, VI material ) { VI res; transform( ALL( box ), material.begin(), back_inserter( res ), divides<int>() ); return accumulate( ALL( res ), 1, multiplies<int>() ); } int main() { cin.tie( 0 ); ios::sync_with_stdio( false ); VI box( 3 ), material( 3 ); FOR( b, box ) { cin >> b; } FOR( m, material ) { cin >> m; } sort( ALL( material ) ); int res = 0; do { res = max( res, check( box, material ) ); } while ( next_permutation( ALL( material ) ) ); cout << res << endl; return 0; }