#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; #define LL long long int N, M; LL Total; LL exist[100001]; LL a[100]; LL res1, res2; void prev(int n,LL val,int bit){ //cout << "prev:" << n << endl; if (n == M){ // cout << val << endl; if (exist[val] == -1 || bit < exist[val]) exist[val] = bit; return; } if (val%a[n] == 0)prev(n - 1, val / a[n], bit + (1 << (n - M - 1))); if (val - a[n]>0)prev(n - 1, val - a[n], bit); return; } bool next(int n, LL val, int bit){ //cout << "next:" << n << endl; if (n == M){ // cout << val << endl; if (exist[val] != -1){ res1 = bit; res2 = exist[val]; return true; } return false; } if (val + a[n+1] <= Total)if (next(n + 1, val+a[n+1], bit))return true; if (val*a[n+1] <= Total)if (next(n + 1, val*a[n+1], bit + (1 << n)))return true; return false; } int main(void){ cin >> N >> Total; for (int i = 0; i <= 100000; i++)exist[i] = -1; for (int i = 0; i < N; i++)cin >> a[i]; M = N / 2; prev(N - 1, Total, 0); next(0, a[0], 0); for (int i = 0; i < N/2; i++) { if (res1&(1 << i))cout << '*'; else cout << '+'; } for (int i = 0; i < (N-1)/2; i++) if (res2&(1 << i))cout << '*'; else cout << '+'; cout << endl; return 0; }