#include #include #include #include #include #include long sub_f1(long total, long value, long depth, long limit_depth, std::vector& v, std::vector& ans) { long temp; if( depth == limit_depth ) { return value; } temp = value + v[depth]; if( temp <= total ) { temp = sub_f1(total, temp, depth+1, limit_depth, v, ans); if( temp == total ) { ans.push_back('+'); return temp; } } temp = value * v[depth]; if( temp <= total ) { temp = sub_f1(total, temp, depth+1, limit_depth, v, ans); if( temp == total ) { ans.push_back('*'); return temp; } } return -1; } int main() { long i, j; long n, m; long total; std::vector v; std::vector ans; long temp; std::cin >> n >> total; for(i = 0; i < n; i++) { std::cin >> temp; v.push_back(temp); } sub_f1(total, v[0], 1, n, v, ans); for(i = ans.size()-1; i >= 0; i--) { std::cout << ans[i]; } std::cout << std::endl; return 0; }