using System; using System.Collections.Generic; public class Program { public void Proc() { Reader.IsDebug = false; int numCount = int.Parse(Reader.ReadLine()); this.Total = int.Parse(Reader.ReadLine()); this.NumList = Reader.GetInt(); this.dic = new string[Total + 1, NumList.Length]; string ans = GetAns(1, NumList[0]); Console.WriteLine(ans); } private int[] NumList; private int Total; private char[] enzan = new char[] {'+', '*'}; private string[,] dic; public String GetAns(int idx, int subTotal) { if(dic[subTotal,idx] != null) { return dic[subTotal,idx]; } string ans = string.Empty; foreach (char c in enzan) { int tmp = subTotal; if(c == '+') { tmp += NumList[idx]; } else { tmp *= NumList[idx]; } if(idx == NumList.Length - 1) { if(tmp == Total) { return c.ToString(); } } else { if(tmp <= Total) { string ret = this.GetAns(idx + 1, tmp); if(ret != null && ret.Length > 0) { return c.ToString() + ret; } } } } dic[subTotal, idx] = ans; return ans; } public class Reader { private static String InitText = @" "; private static System.IO.StringReader sr = null; public static bool IsDebug = true; public static string ReadLine() { if(IsDebug) { if(sr == null) { sr = new System.IO.StringReader(InitText.Trim()); } return sr.ReadLine(); } else { return Console.ReadLine(); } } public static int[] GetInt(char delimiter = ' ') { string[] inpt = ReadLine().Split(delimiter); int[] ret = new int[inpt.Length]; for(int i=0; i