using System; using System.Collections.Generic; using System.Text; using System.Linq; class Program { public void Proc() { Reader.IsDebug = false; this.Init(); int inputCount = int.Parse(Reader.ReadLine()); for(int i=0; i[] dic = new Dictionary[9]; private long GetAnsSub(int idx, long remain) { if(this.dic[idx] == null) { this.dic[idx] = new Dictionary(); } if(this.dic[idx].ContainsKey(remain)) { return dic[idx][remain]; } if(remain == 0) { return 1; } if(remain < this.CoinList.Last()) { return 1; } long ans = 1; for(int i=idx; i remain) { continue; } long ret = this.GetAnsSub(i, remain - this.CoinList[i]); ans += ret % ModNum;; } ans = ans % ModNum; this.dic[idx].Add(remain, ans); return ans; } private long ModNum = 1000000000 + 9; private List CoinList = new List(); private void Init() { long[] dat = new long[]{111111,222222,333333,444444,555555,666666,777777,888888,999999}; CoinList.AddRange(dat); this.CoinList.Reverse(); } public class Reader { public static bool IsDebug = true; private static String PlainInput = @" 7 1 111112 222222 10000000 100000000 1000000000 10000000000 "; 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(); } } } static void Main() { Program prg = new Program(); prg.Proc(); } }