#include #include using namespace std; int n; int t; int nums[50]; char op[50]; bool visited[50][100001]; void Calc(int current, int value) { if (value > t) return; if (current == n) { if (value < t) return; op[n - 1] = '\0'; cout << string(op) << endl; exit(0); } if (visited[current][value]) return; visited[current][value] = true; int op_index = current - 1; op[op_index] = '+'; Calc(current + 1, value + nums[current]); op[op_index] = '*'; Calc(current + 1, value * nums[current]); } int main() { cin >> n >> t; for (int i = 0; i < n; i++) { cin >> nums[i]; } Calc(1, nums[0]); return 0; }