//http://yukicoder.me/problems/29 #include #include #include #include #include #include #include #include #include #include #include using namespace std; int main() { int N; cin >> N; int Total; cin >> Total; vector A(N); for (int i = 0; i < N; i++) { cin >> A[i]; } vector> dp(N, vector(Total + 1, numeric_limits::max())); dp[0][A[0]] = 0; for (int i = 1; i < N; i++) { for (int j = 1; j <= Total; j++) { if (dp[i - 1][j] != numeric_limits::max()) { int n = j + A[i]; if (n <= Total) { auto v = dp[i - 1][j]; if (dp[i][n] > v) dp[i][n] = v; } int m = j * A[i]; if (m <= Total) { auto v = dp[i - 1][j] | (1LL << (N - i)); if (dp[i][m] > v) dp[i][m] = v; } } } } string ans; for (int i = 0; i < N - 1; i++) { if (dp[N - 1][Total] & (1LL << (N - i - 1))) ans += "*"; else ans += "+"; } cout << ans << endl; return 0; }