#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #define LL long long #define PI acos(-1) #define INF 1e8 #define EPS 1e-9 using namespace std; #define MAX_N 51 #define MAX_TOTAL 100001 int N; int Total; int A[MAX_N]; string mMin(string s1, string s2){ if(s1 == "-1" && s2 != "-1") return s2; else if(s1 != "-1" && s2 == "-1") return s1; if(s1 == s2) return s1; for(int i = 0; i < min(s1.length(), s2.length()); i++){ if(s1[i] == '+' && s2[i] == '*'){ return s1; } else if(s1[i] == '*' && s2[i] == '+'){ return s2; } } if(s1.length() < s2.length()) return s1; else return s2; } string dp[MAX_N][MAX_TOTAL]; void init(){ for(int i = 0; i < MAX_N; i++){ for(int j = 0; j < MAX_TOTAL; j++){ dp[i][j] = "-1"; } } } int main(){ cin >> N; cin >> Total; for(int i = 0; i < N; i++){ cin >> A[i]; } init(); dp[0][A[0]] = ""; for(int i = 0; i < N-1; i++){ for(int j = 0; j <= Total; j++){ if(dp[i][j] == "-1") continue; int nextInt = j + A[i+1]; if(nextInt <= Total){ dp[i+1][nextInt] = mMin(dp[i+1][nextInt], dp[i][j] + "+"); } nextInt = j * A[i+1]; if(nextInt <= Total){ dp[i+1][nextInt] = mMin(dp[i+1][nextInt], dp[i][j] + "*"); } } } cout << dp[N-1][Total] << endl; return 0; }