// yukicoder: No.10 +か×か // 2019.4.8 bal4u // 全検索 #include #if 0 #define gc() getchar_unlocked() #define pc(c) putchar_unlocked(c) #else #define gc() getchar() #define pc(c) putchar(c) #endif int in() { int n = 0, c = gc(); do n = 10 * n + (c & 0xf), c = gc(); while (c >= '0'); return n; } void outs(char *s) { while (*s) pc(*s++); } int a[55]; char ans[55]; int N, total; int calc(int id, int val) { int res; if (id >= N) return (val == total); res = val + a[id], ans[id] = '+'; if (calc(id + 1, res)) return 1; res = val * a[id], ans[id] = '*'; if (calc(id + 1, res)) return 1; return 0; } int main() { int i; N = in(), total = in(); for (i = 0; i < N; i++) a[i] = in(); calc(1, a[0]); outs(ans + 1), pc('\n'); return 0; }