voidGauss() { for (int i = 1; i <= n; ++ i) { int t = -1; for (int j = i; j <= n; ++ j) if (a[j][i]) { t = j; break; } assert(~t); if (t ^ i) std::swap(a[t], a[i]); int Inv = qpow(a[i][i]); for (int j = i; j <= n + 1; ++ j) a[i][j] = (LL) a[i][j] * Inv % Mod; for (int j = 1; j <= n; ++ j) if (j != i && a[j][i]) for (int k = n + 1; k >= i; -- k) a[j][k] = (a[j][k] + (LL) (Mod - a[j][i]) * a[i][k]) % Mod; } }
BigNum operator +(BigNum a, BigNum b) { BigNum res; int len = std::max(a.len(), b.len()), ls = 0; a.a.resize(len), b.a.resize(len); for (int i = 0; i < len; ++ i) res.a.push_back((a[i] + b[i] + ls) % 10), ls = (a[i] + b[i] + ls) >= 10; if (ls) res.a.push_back(ls); return res; }
BigNum operator *(BigNum a, int k) { if (!k) return {}; BigNum res; LL ls = 0; for (int x : a.a) ls = (LL) x * k + ls, res.a.push_back(ls % 10), ls /= 10; while (ls) res.a.push_back(ls % 10), ls /= 10; return res; }
std::istream& operator >>(std::istream &fin, BigNum &res) { std::string buf; fin >> buf; std::reverse(buf.begin(), buf.end()); int len = buf.length(); for (int i = 0; i < len; ++ i) res.a.push_back(buf[i] ^ 48); return fin; }
intsolve(BigNum le) { Node res; res.a.resize(n + 1); int ls = 9, sum = 0; for (int i = le.len() - 1; ~i; -- i) sum = (sum * 10LL + le[i]) % Mod; for (int i = le.len() + 1; i <= mxlen; ++ i) for (int j = 1; j <= 9; ++ j) res += dp[i][j] * Node(Mod - sum); for (int i = le.len() - 1; ~i; -- i) { for (int j = le[i] + 1; j <= ls; ++ j) res += dp[i + 1][j] * Node(Mod - sum); if (le[i] > ls) break; sum = (sum + (LL) (Mod - pw10[i]) * le[i]) % Mod, ls = le[i]; if (i == 0) res += Node(0); } int ret = 0; for (int i = 0; i < n; ++ i) ret = (ret + (LL) res[i] * a[i + 1][n + 1]) % Mod; // std::cout << ret << ' ' << le << '\n'; return ret; }
intmain() { // freopen("digit.in", "r", stdin); // freopen("digit.out", "w", stdout); std::cin >> L >> R >> n, mxlen = R.len() + 3; for (int i = C[0][0] = 1; i < N; ++ i) for (int j = C[i][0] = 1; j <= i; ++ j) adj(C[i][j] = C[i - 1][j - 1] + C[i - 1][j] - Mod); for (int i = pw10[0] = 1; i <= mxlen; ++ i) pw10[i] = pw10[i - 1] * 10LL % Mod; for (int i = 2; i <= mxlen; ++ i) for (int j = 0; j <= 9; ++ j) dp[i][j].a.resize(n + 1); for (int j = 0; j <= 9; ++ j) dp[1][j] = Node(j); for (int l = 1; l < mxlen; ++ l) for (int i = 0; i <= 9; ++ i) for (int j = i; j <= 9; ++ j) dp[l + 1][j] += dp[l][i] * Node(pw10[l] * (LL) j % Mod); for (int i = 1; i <= n; ++ i) for (int j = 1; j <= n; ++ j) a[i][j] = qpow(i, j - 1); for (int i = 1; i <= n; ++ i) a[i][n + 1] = C[i + n - 1][n - 1]; Gauss();
// mxlen = 2, solve(10), exit(0); int res = 0; for (int i = 0, op = 1; i <= n; ++ i, op = Mod - op) res = (res + solve(L * (n - i) + (R + 1) * i) * (LL) C[n][i] % Mod * op) % Mod; std::cout << res << std::endl; return0; }