#include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; #define REP(i,a,n) for(int i=(a); i<(int)(n); i++) #define rep(i,n) REP(i,0,n) #define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it) #define ALLOF(c) (c).begin(), (c).end() typedef long long ll; int dp[55][100005]; int type[55][100005]; int main(){ int N, total, a; vector A; cin >> N; cin >> total; rep(i,N){ cin >> a; A.push_back(a); } dp[0][A[0]] = 1; REP(i,1,N){ rep(j,total+1){ if(dp[i-1][j] == 1){ if(j+A[i]<=total){ if(dp[i][j+A[i]] == 0){ dp[i][j+A[i]] = 1; type[i][j+A[i]] = 1; } } if(j*A[i]<=total){ if(dp[i][j*A[i]] == 0){ dp[i][j*A[i]] = 1; type[i][j*A[i]] = 2; } } } } } rep(i,N){ rep(j,total+1){ cout << " " << dp[i][j] << "(" << type[i][j] << ")"; } cout << endl; } vector ret; int now = total; for(int i=N-1; i>0; i--){ ret.push_back(type[i][now]); if(type[i][now] == 1){ now -= A[i]; }else{ now /= A[i]; } } reverse(ALLOF(ret)); rep(i,ret.size()){ if(ret[i] == 1){ cout << "+"; }else{ cout << "*"; } } cout << endl; return 0; }