using System; using System.IO; using System.Linq; using System.Collections.Generic; public class Program { public void Proc() { this.Target = Reader.ReadLine(); long[] ans = new long[2]; for (int i = 1; i <= this.Target.Length; i++) { long[] tmp = GetAns(i, true); ans[0] += tmp[0]; ans[1] += tmp[1]; ans[0] = ans[0] % ModZero; ans[1] = ans[1] % Mod; } Console.WriteLine(ans[0]); Console.WriteLine(ans[1]); } private Dictionary> dic = new Dictionary>(); private string Target; private bool IsBigger(string num) { if(num.Length > Target.Length) { return true; } if(num.Length < Target.Length) { return false; } for (int i = 0; i < num.Length; i++) { if(num[0]>Target[0]) { return true; } if(num[0]()); } if(dic[keta].ContainsKey(rmZero)) { return dic[keta][rmZero]; } if(keta == 1) { if(Target.Length == 1) { int tmp = int.Parse(Target); return new long[] { tmp, tmp }; } if(rmZero) { return new long[] { 9, 9 }; } return new long[] { 10, 10 }; } if(keta == 2) { if(Target.Length == 2) { int tmp = int.Parse(Target); int cnt = 0; for (int i = 1; i * 11 <= tmp; i++) { cnt++; } return new long[] { cnt, cnt }; } if(rmZero) { return new long[] { 9, 9 }; } return new long[] { 10, 10 }; } long[] baseNum = GetAns(keta - 2, false).ToArray(); long[] ans = new long[2]; if(keta < this.Target.Length) { if(rmZero) { ans[0] = baseNum[0] * 9; ans[1] = baseNum[1] * 9; } else { ans[0] = baseNum[0] * 10; ans[1] = baseNum[1] * 10; } } else { ans = GetTargetSmallerNum(0); } ans[0] = ans[0] % ModZero; ans[1] = ans[1] % Mod; dic[keta][rmZero] = ans; return ans; } private long[] GetTargetSmallerNum(int idx) { if (idx >= Target.Length) { return new long[] { 0, 0 }; } int num = int.Parse(Target[idx].ToString()); int keta = Target.Length - idx - 1; long[] tmp = new long[2]; if(num>=1) { tmp = GetAns(keta, false).ToArray(); tmp[0] *= (num - 1); tmp[1] *= (num - 1); } long[] tmp2 = GetTargetSmallerNum(idx + 1).ToArray(); long[] ans = new long[] { tmp[0] + tmp2[0], tmp[1] + tmp2[1] }; ans[0] = ans[0] % ModZero; ans[1] = ans[1] % Mod; return ans; } private long ModZero = 1000000000; private long Mod = 1000000000 + 7; 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 = @" 1000000000000000000000000000000 "; } public static void Main(string[] args) { #if DEBUG Reader.IsDebug = true; #endif Program prg = new Program(); prg.Proc(); } }