#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; LL 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; } } LL temp; LL mask = (LL)1<<(N-2); dp[ A[0] ][0] = 0; for(int i=1;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] + mask ); } } } mask = mask >> 1; } LL ans = dp[total][N-1]; mask = (LL)1<<(N-2); rep(i,N-1){ if( ans & mask ){ cout << "*"; }else{ cout << "+"; } mask = mask>>1; }cout << endl; return 0; }