#include #include #include using namespace std; const int MAX_N = 60; const int MAX_TOTAL = 100010; int a[MAX_N]; vector dp[MAX_N][MAX_TOTAL]; int main() { int n, total; cin >> n >> total; for (int i = 0; i < n; i++) { cin >> a[i]; } // 初期化 for (int i = 0; i <= n; i++) { for (int tot = 0; tot <= total; tot++) { dp[i][tot] = vector(i + 1, 0); } } dp[0][a[0]] = vector{'~'}; for (int i = 1; i < n; i++) { for (int tot = 0; tot <= total; tot++) { vector hist; // + if (tot - a[i] >= 0) { hist = dp[i - 1][tot - a[i]]; hist.push_back('+'); dp[i][tot] = max(dp[i][tot], hist); } // * if (tot % a[i] == 0) { hist = dp[i - 1][tot / a[i]]; hist.push_back('*'); dp[i][tot] = max(dp[i][tot], hist); } } } for (int i = 1; i < dp[n - 1][total].size(); i++) { cout << dp[n - 1][total][i]; } cout << endl; return 0; }