using System; using System.Collections.Generic; using System.IO; using System.Linq; public class YukiCoder { private static int N; private static int Total; private static int[] A; private static string Anser = string.Empty; public static void Solve() { N = MyConsole.Int(); Total = MyConsole.Int(); A = MyConsole.IntSplit(); // 演算の実行 Math( "", A[0], 1 ); MyConsole.wLine( Anser ); } /// /// Total に達するまで+と×の組み合わせを変えながら演算を行う。 /// 組み合わせは辞書順の上から総当りの手法。 /// /// 計算式 /// 経過値 /// 位置情報 /// 終わっている?[true:終わった false:まだまだ!] private static bool Math( string Formula, int Base, int Index ) { if (Base == Total && Index == N) { Anser = Formula; return true; } else if (Base > Total || Index >= N) { return false; } Math( Formula + "+", Base + A[Index], Index + 1 ); Math( Formula + "*", Base * A[Index], Index + 1 ); return false; } public static void Main() { MyConsole.Read(); Solve(); MyConsole.Finish(); } } public static class MyConsole { private static List ReadedLine = new List(); private static char[] buf = new char[1024]; private static int i; public static void Read() { string sr = Console.In.ReadToEnd(); ReadedLine = sr.Split( new[] { '\r', '\n' }, StringSplitOptions.RemoveEmptyEntries ).ToList(); Console.SetOut( new StreamWriter( Console.OpenStandardOutput() ) { AutoFlush = false } ); } public static string String() { return ReadedLine[i++]; } public static string[] StringSplit() { return ReadedLine[i++].Split( new[] { ' '} ); } public static int Int() { return int.Parse( ReadedLine[i++] ); } public static int[] IntSplit() { string[] strs = StringSplit(); int[] ret = new int[strs.Length]; for (int i = 0 ; i < strs.Length ; i++) { ret[i] = int.Parse( strs[i] ); } return ret; } public static long Long() { return long.Parse( ReadedLine[i++] ); } public static double Double() { return double.Parse( ReadedLine[i++] ); } public static void wLine( string output = null ) { Console.WriteLine( output ); } public static void Finish() { Console.Out.Flush(); } }