#define _USE_MATH_DEFINES #include #include #include #include #include #include //#include #include #include #include #include #include #include ///////// #define REP(i, x, n) for(int i = x; i < n; i++) #define rep(i,n) REP(i,0,n) #define P(p) cout<<(p)< ///////// typedef long long LL; typedef long double LD; ///////// using namespace::std; ///////// int N; int total; int A[50]; int dpmax = 100001; LL dp[100001][51]; int main(void){ std::cin.tie(0); std::ios::sync_with_stdio(false); std::cout << std::fixed;// //cout << setprecision(16);// cin>>N>>total; rep(i,N){//[0-N) 0ori N個 cin>>A[i]; } const LL INF = (LL)1<<55; rep(i,100001){ rep(j,51){ dp[i][j] = INF; } } dp[ A[0]+A[1] ][1] = 0; dp[ A[0]*A[1] ][1] = (LL)1<<(N-2-0); LL temp; for(int i=2;i=1;--j){ if( dp[j][i-1] < INF && 0 <= dp[j][i-1] ){ temp = j + A[i]; if( temp <= total){ dp[ temp ][i] = min( dp[ temp ][i] , dp[j][i-1] ); } temp = j * A[i]; if( temp <= total ){ dp[ temp ][i] = min( dp[ temp ][i] , dp[j][i-1] + (LL)( 1<<(N-1-i) ) ); } } } } LL ans = dp[total][N-1]; rep(i,N-1){ if( ans & (LL)(1<<(N-2-i)) ){ cout << "*"; }else{ cout << "+"; } }cout << endl; return 0; }