#include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; /* namespace std { template<> class hash > { public: size_t operator()(const std::pair& x) const { return hash()(x.first) ^ hash()(x.second); } }; } */ #define endl '\n' #define all(v) (v).begin(), (v).end() #define uniq(v) (v).erase(unique((v).begin(), (v).end()), (v).end()) typedef long long ll; typedef pair P; typedef unsigned int uint; struct pairhash { public: template size_t operator()(const pair &x) const { size_t seed = hash()(x.first); return hash()(x.second) + 0x9e3779b9 + (seed<<6) + (seed>>2); } }; /* struct PEqual { bool operator(const P& a, const P& b) const { return a.first == b.first && a.second == b.second; } }; */ const int inf = 1000000009; int n, t; int as[51]; char res[51]; unordered_set memo; bool dfs(int k, int num) { if (memo.count(P(k, num)) > 0) return false; if (k == n) { return num == t; } else { if (num + as[k] <= t && dfs(k+1, num+as[k])){ res[k-1] = '+'; return true; } if (num * as[k] <= t && dfs(k+1, num*as[k])) { res[k-1] = '*'; return true; } memo.insert(P(k, num)); return false; } } int main() { scanf("%d%d", &n, &t); for (int i = 0; i < n; i++) scanf("%d", &as[i]); dfs(1, as[0]); for (int i = 0; i < n-1; i++) printf("%c", res[i]); printf("\n"); }