#include #include #include using namespace std; template T find(T first, T last, U val, V func){ for(; first != last; first++) if(func(val, *first)) return first; return last; } int main(){ int64_t n, total; cin >> n >> total; int64_t a[n]; for(int i = 0; i < n; i++) cin >> a[i]; vector> v; v.emplace_back(make_pair(a[0], "")); for(int i = 1; i < n; i++){ vector> next; for(auto p:v){ if(p.first + a[i] <= total) next.emplace_back(make_pair(p.first + a[i], p.second + '+')); if(p.first * a[i] <= total) next.emplace_back(make_pair(p.first * a[i], p.second + '*')); } v = next; } sort(v.begin(), v.end(), [](pair p, pair q){return p.first == q.first ? p.second > q.second : p.first < q.first;}); for(auto p:v) cerr << p.first << ' ' << p.second << endl; cout << find(v.begin(), v.end(), make_pair(total, ""), [](pair p, pair q){return p.first == q.first;})->second << endl; }