#include #include using namespace std; using i64 = long long; int main(void) { int n; scanf("%d", &n); int total; scanf("%d", &total); vector a(n); // a[n] for(int i=0; i dp(total+1, -1); // dp[total+1] dp[0] = 0; for(int i=0; i ndp(total+1, -1); // ndp[total+1] for(int j=0; j<=total; ++j) { if(dp[j] == -1) { continue; } if(j + a[i] <= total) { ndp[j+a[i]] = max(ndp[j+a[i]], (dp[j] << 1) + 1); } if(j * a[i] <= total) { ndp[j*a[i]] = max(ndp[j*a[i]], dp[j] << 1); } } dp = ndp; } string res = ""; for(i64 val=dp[total]; val; val>>=1) { res += "*+"[val & 1]; } reverse(begin(res), end(res)); res = res.substr(1); puts(res.c_str()); return 0; }