#include #define FOR(i, a, b) for (int i = (a); i < (b); i++) #define RFOR(i, a, b) for (int i = (b)-1; i >= (a); i--) #define rep(i, n) for (int i = 0; i < (n); i++) #define rep1(i, n) for (int i = 1; i <= (n); i++) #define rrep(i, n) for (int i = (n)-1; i >= 0; i--) #define pb push_back #define mp make_pair #define fst first #define snd second #define show(x) cout << #x << " = " << x << endl #define chmin(x, y) x = min(x, y) #define chmax(x, y) x = max(x, y) #define pii pair #define vi vector using namespace std; template ostream& operator<<(ostream& o, const pair& p) { return o << "(" << p.first << "," << p.second << ")"; } template ostream& operator<<(ostream& o, const vector& vc) { o << "sz = " << vc.size() << endl << "["; for (const T& v : vc) o << v << ","; o << "]"; return o; } using ll = long long; constexpr ll MOD = 1000000007; constexpr int MAX = 50; constexpr int VMAX = 100000; int num[MAX]; int dp[MAX][VMAX + 1]; string decode(int ope) { string str; while (ope > 1) { str.push_back((ope % 2 == 0) ? '+' : '*'); ope /= 2; } reverse(str.begin(), str.end()); return str; } int main() { int n; cin >> n; int total; cin >> total; rep(i, n) { cin >> num[i]; } rep(i, n) { rep(v, VMAX + 1) { dp[i][v] = numeric_limits::max(); } } dp[0][num[0]] = 1; rep1(i, n - 1) { rep(v, VMAX + 1) { if (dp[i - 1][v] != numeric_limits::max()) { if (v + num[i] <= VMAX) { dp[i][v + num[i]] = min(dp[i][v + num[i]], 2 * dp[i - 1][v]); } if (v * num[i] <= VMAX) { dp[i][v * num[i]] = min(dp[i][v * num[i]], 2 * dp[i - 1][v] + 1); } } } } cout << decode(dp[n - 1][total]) << endl; return 0; }