#include #include #include #include using namespace std; template inline bool chmax(T &a, T b) { return a < b ? (a = b, 1) : 0; } int main() { assert("*" < "+" && "+" < "@"); int n; cin >> n; int total; cin >> total; vector a(n); for (auto &ai: a) cin >> ai; vector> dp(n, vector(total + 1)); dp[0][a[0]] = "@"; for (int i = 0; i + 1 < n; i++) for (int j = 0; j <= total; j++) { if (j + a[i + 1] <= total) { chmax(dp[i + 1][j + a[i + 1]], dp[i][j] + "+"); } if (j * a[i + 1] <= total) { chmax(dp[i + 1][j * a[i + 1]], dp[i][j] + "*"); } } cout << dp.back()[total].substr(1) << endl; return 0; }