using System; using System.IO; using System.Linq; using System.Collections.Generic; using System.Text; public class Program { public void Proc() { int inpt = int.Parse(Reader.ReadLine()); StringBuilder ans = new StringBuilder(); for (int i = 0; i < inpt; i++) { ans.AppendLine(Increment(Reader.ReadLine())); } Console.Write(ans.ToString()); } private string Increment(string str) { int fromIdxMax = -1; int toIdxMax = -2; int fromIdx = -1; int toIdx = -1; for (int i = 0; i < str.Length; i++) { if(str[i]>='0'&&str[i]<='9') { if (fromIdx<=0) { fromIdx = i; } toIdx = i; } else { if (toIdx - fromIdx >= toIdxMax - fromIdxMax) { fromIdxMax = fromIdx; toIdxMax = toIdx; } fromIdx = -1; toIdx = -1; } } if (toIdx - fromIdx >= toIdxMax - fromIdxMax) { fromIdxMax = fromIdx; toIdxMax = toIdx; } if (fromIdxMax>=0) { string subStr1 = str.Substring(0, fromIdxMax); string subStr2 = str.Substring(toIdxMax + 1); int num = int.Parse(str.Substring(fromIdxMax, toIdxMax - fromIdxMax + 1)); num++; return subStr1 + num + subStr2; } else { return str; } } public class Reader { private static StringReader sr; public static bool IsDebug = false; public static string ReadLine() { if (IsDebug) { if (sr == null) { sr = new StringReader(InputText.Trim()); } return sr.ReadLine(); } else { return Console.ReadLine(); } } private static string InputText = @" 5 yuki2006 rng_58 sugim48 02/29/2016 D programming language version 0.99 "; } public static void Main(string[] args) { #if DEBUG Reader.IsDebug = true; #endif Program prg = new Program(); prg.Proc(); } }