#include using namespace std; using Int32 = int_fast32_t; using Word32 = uint_fast32_t; using Int64 = int_fast64_t; using Word64 = uint_fast64_t; using Int128 = __int128_t; using Word128 = __uint128_t; using Int = int_fast64_t; using Word = uint_fast64_t; using F32 = float; using F64 = double; using F80 = long double; using VInt = vector; using VVI = vector; using VWord = vector; using VVW = vector; using VF32 = vector; using VF64 = vector; using VF80 = vector; using VS = vector; using VVS = vector; using VB = vector; using VVB = vector; using PII = pair; using PWW = pair; using VPII = vector; using VPWW = vector; using PQ_PII = priority_queue>; #define SZ(x) ((Int)(x).size()) #define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end()) #define rep(i,n) for(Int i=0, i##_len=(n); i> n; Int total; cin >> total; Int a[51]; for (Int i = n - 1; i >= 0; i--) cin >> a[i]; bool dp[51][100001] = {}; dp[0][total] = true; rep(i,n)rep(j,100001) { if (!dp[i][j]) continue; if (j - a[i] >= 0) dp[i + 1][j - a[i]] = true; if (j % a[i] == 0) dp[i + 1][j / a[i]] = true; } Int val = a[n - 1], pos = n - 2; while (pos >= 0) { if (dp[pos][val + a[pos]]) { val += a[pos]; cout << '+'; } else { val *= a[pos]; cout << '*'; } pos--; } cout << '\n'; return 0; }