using System; using System.Collections.Generic; using System.Linq; class Solution { // 9で埋められる桁数 static int GetDigits(ulong u) { int i = 0; while (u > 0) { i++; u /= 10; } return Math.Max(i - 1, 0); } // 最上位桁とそれ以外に分割 static ulong[] Split(ulong u) { var result = new ulong[2]; var str = u.ToString(); result[0] = ulong.Parse(str.Substring(0, 1)); result[1] = 0; if (u >= 10) { result[1] = ulong.Parse(str.Substring(1)); } return result; } static void Main() { // 桁数 -> 回分数 var palindromeA = new Dictionary() { { 0, 1 }, { 1, 9 }, { 2, 9 * 2 } }; var palindromeB = new Dictionary() { { 0, 1 }, { 1, 9 }, { 2, 9 * 2 } }; for (int i = 3; i < 18; i++) { var palA = (9 * Enumerable.Repeat(10uL, (i - 1) / 2).Aggregate((m, next) => (m * next) % 1000000000)) + palindromeA[i - 1]; palA %= 1000000000; var palB = (9 * Enumerable.Repeat(10uL, (i - 1) / 2).Aggregate((m, next) => (m * next) % 1000000007)) + palindromeB[i - 1]; palB %= 1000000007; palindromeA[i] = palA; palindromeB[i] = palB; } ulong resultA = 0; ulong resultB = 0; var n = ulong.Parse(Console.ReadLine()); ulong mult = 1; while (mult > 0) { int digits = GetDigits(n); var vals = Split(n); mult = vals[0]; n = vals[1]; Console.Error.WriteLine($"{mult} {n} {digits}"); resultA += (palindromeA[digits] * mult) % 1000000000; resultB += (palindromeB[digits] * mult) % 1000000007; } Console.WriteLine(resultA); Console.WriteLine(resultB); } }