#include void numin(int index, int *numBox) { char str; for (int i = 0; i '9') cnt++; else numBox[cnt] = numBox[cnt] * 10 + (int)str - (int)'0'; } } int main() { int number=0; int total =0; int value[50]; // 入力処理 scanf("%d", &number); scanf("%d", &total); printf("%d\n", number); printf("%d\n", total); numin(number, value); for (int i = 0; i < number; i++) printf("%d ", value[i]); unsigned long long switcher = 0; int plus = 0; if(number > 3){} for (int i = 2; i < number; i++) plus += value[i]; if (plus + value[0] + value[1] != total) { switcher = 1; int ans = value[0]; unsigned long long cursor = 1; int point = 2; // 計算処理 while (1) { // 計算 for (int i = 0; i < (int)cursor; i++) { if ((switcher >> i) & 1) ans *= value[i + 1]; else ans += value[i + 1]; } if (total == ans + plus) break; ans = value[0]; if (++switcher == point) { plus -= value[++cursor]; point *= 2; } } } // 結果表示 for (int i = 0; i < number - 1; i++) { if ((switcher >> i) & 1) printf("*"); else printf("+"); } return 0; }