#include #include #include #include #include using namespace std; int n, total; vector a; string ans; bool fail[50][100000]; bool calc(int result, int idx) { if (idx == n) { // cout << ans << " " << result << endl; if (result == total) { return true; } return false; } if (fail[idx][result]) { return false; } for (int i = 0; i < 2; i++) { int next; if (i == 0) { ans[idx - 1] = '+'; next = result + a[idx]; } else { ans[idx - 1] = '*'; next = result * a[idx]; } if (next <= total) { if (calc(next, idx + 1)) { return true; } else { fail[idx][result] = true; } } } return false; } int main() { cin >> n; cin >> total; a.assign(n, 0); ans.assign(n - 1, '?'); for (int i = 0; i < n; i++) { cin >> a[i]; } calc(a[0], 1); cout << ans << endl; return 0; }