「题解」Codeforces 468C Hack it!
被构造橄榄了/ll
当 \(i<10^{18}\) 时,有 \(f(i)=f(i+10^{18})+1\).
设 \(s=\sum_{i=1}^{10^{18}}f(i)\),根据结论,可以归纳证明 \(\sum_{i=1+b}^{10^{18}+b}f(i)=s+b\pmod a\),所以当 \(b=-s\pmod a\) 的时候,构造 \(L=1+b,r=10^{18}+b\) 即可满足条件。
如何求出 \(s\)?求 \(\sum_{i=1}^{10^{18}-1}\) 再 \(+1\) 即可得到。
考虑任意一位数的贡献,其为 \((0+1+2+3+...+9)\times 10^{17}\),一共有 \(18\) 位,所以 \(s=45\times 18\times 10^{17}=81\times 10^{18}\).
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<vector>
#define pb emplace_back
#define mp std::make_pair
#define fi first
#define se second
typedef long long ll;
typedef std::pair<int, int> pii;
typedef std::pair<ll, int> pli;
typedef std::pair<ll, ll> pll;
typedef std::vector<int> vi;
typedef std::vector<ll> vll;
const ll mod = 998244353;
ll Add(ll x, ll y) { return (x+y>=mod) ? (x+y-mod) : (x+y); }
ll Mul(ll x, ll y) { return x * y % mod; }
ll Mod(ll x) { return x < 0 ? (x + mod) : (x >= mod ? (x-mod) : x); }
ll cadd(ll &x, ll y) { return x = (x+y>=mod) ? (x+y-mod) : (x+y); }
template <typename T> T Max(T x, T y) { return x > y ? x : y; }
template <typename T> T Min(T x, T y) { return x < y ? x : y; }
template <typename T>
T &read(T &r) {
r = 0; bool w = 0; char ch = getchar();
while(ch < '0' || ch > '9') w = ch == '-' ? 1 : 0, ch = getchar();
while(ch >= '0' && ch <= '9') r = r * 10 + (ch ^ 48), ch = getchar();
return r = w ? -r : r;
}
ll a, b, s = 1000000000000000000ll;
signed main() {
read(a); s %= a; b = a-(s*9%a*9%a+1)%a;
printf("%lld %lld\n", b+1, b+1000000000000000000ll);
return 0;
}