using System; using System.Collections.Generic; using System.Text; using System.Linq; class Program { public void Proc() { Reader.IsDebug = false; string[] inpt = Reader.ReadLine().Split(' '); ulong numA = ulong.Parse(inpt[0]); ulong numB = ulong.Parse(inpt[1]); for(ulong i=numA; i<= numB; i++) { string str = i.ToString("#############################0"); if(i % 3 == 0 || str.IndexOf('3') >= 0) { Console.WriteLine(str); } } } private String GetAns(List target, string totyu) { int len = Math.Min(totyu.Length, this.MinAns.Length); for(int i=0; i MinAns[i]) { return string.Empty; } if(totyu[i] < MinAns[i]) { MinAns = totyu; break; } } if(totyu.Length > this.MinAns.Length) { MinAns = totyu; } string ans = string.Empty; if(target.Count == 1) { ans = totyu + target[0]; if(this.MinAns.Length < ans.Length && ans.StartsWith(this.MinAns)) { this.MinAns = ans; return ans; } else if(this.MinAns.CompareTo(ans) > 0) { this.MinAns = ans; return ans; } else { return string.Empty; } } char first = target[0][0]; for(int i=0; i subList = new List(target); if(subList[i].Length == 1) { subList.RemoveAt(i); } else { subList[i] = subList[i].Substring(1); } subList.Sort(); string tmp = this.GetAns(subList, totyu + target[i][0]); if(tmp.Length > 0) { if(ans.Length == 0 || tmp.CompareTo(ans) < 0) { ans = tmp; } } } return ans; } private string MinAns = string.Empty; private List InputList = new List(); public class Reader { public static bool IsDebug = true; private static String PlainInput = @" 30 40 "; private static System.IO.StringReader Sr = null; public static string ReadLine() { if (IsDebug) { if (Sr == null) { Sr = new System.IO.StringReader(PlainInput.Trim()); } return Sr.ReadLine(); } else { return Console.ReadLine(); } } public static int[] GetInt(char delimiter = ' ', bool trim = false) { string inptStr = ReadLine(); if (trim) { inptStr = inptStr.Trim(); } string[] inpt = inptStr.Split(delimiter); int[] ret = new int[inpt.Length]; for (int i = 0; i < inpt.Length; i++) { ret[i] = int.Parse(inpt[i]); } return ret; } } static void Main() { Program prg = new Program(); prg.Proc(); } }