using System; using System.Collections.Generic; using System.Linq; class Program { static string InputPattern = "Input5"; static List<string> GetInputList() { var WillReturn = new List<string>(); if (InputPattern == "Input1") { WillReturn.Add("4"); WillReturn.Add("41"); WillReturn.Add("32"); WillReturn.Add("23"); WillReturn.Add("14"); //9 } else if (InputPattern == "Input2") { WillReturn.Add("9"); WillReturn.Add("000223444444"); WillReturn.Add("00003641077"); WillReturn.Add("0001783660"); WillReturn.Add("00002DOOO"); WillReturn.Add("00052KC0"); WillReturn.Add("0064JJJ"); WillReturn.Add("0BG938"); WillReturn.Add("F423F"); WillReturn.Add("UGHV"); //999999 } else if (InputPattern == "Input3") { WillReturn.Add("7"); WillReturn.Add("YUKICODER"); WillReturn.Add("TOPCODER"); WillReturn.Add("ATCODER"); WillReturn.Add("CODEFORCES"); WillReturn.Add("CODECHEF"); WillReturn.Add("AIZUONLINE"); WillReturn.Add("HACKERRANK"); //8005080147 } else if (InputPattern == "Input4") { WillReturn.Add("1"); WillReturn.Add("0XFFFFFFFFFF"); //69062819408545233 //先頭が0Xだからといって16進数であるわけではありません。 } else { string wkStr; while ((wkStr = Console.ReadLine()) != null) WillReturn.Add(wkStr); } return WillReturn; } static void Main() { List<string> InputList = GetInputList(); string[] VArr = InputList.Skip(1).Distinct().ToArray(); //foreach (string EachStr in VArr) { // Console.WriteLine(DeriveVal(EachStr)); //} Console.WriteLine(VArr.Min(X => DeriveVal(X))); } //解釈できるうちで最小の数を、Decimal型で返す static decimal DeriveVal(string pTarget) { int ShinSuu = DeriveShinSuu(pTarget); //Console.WriteLine("{0}は{1}進数", pTarget, ShinSuu); decimal WillReturn = 0; for (int I = 0; I <= pTarget.Length - 1; I++) { char CurrChar = pTarget[pTarget.Length - 1 - I]; int CurrInt; if (CurrChar <= '9') CurrInt = CurrChar - '0'; else CurrInt = CurrChar - 'A' + 10; WillReturn += DeriveBekijyou(CurrInt, ShinSuu, I); } return WillReturn; } //何進数かを求める static int DeriveShinSuu(string pTarget) { //最大の文字 char MaxChar = pTarget.Max(); if (MaxChar <= '9') return MaxChar - '0' + 1; return MaxChar - 'A' + 10 + 1; } //X*(AのN乗)をDecimal型で返す static decimal DeriveBekijyou(int pX, int pA, int pN) { decimal WillReturn = pX; for (int I = 1; I <= pN; I++) { WillReturn *= pA; } return WillReturn; } }