Solution
可以发现当 (xleq10^{18}) 时, (f(x)+1=f(10^{18}+x)) ,令 (g_x=sumlimits_{i=1}^xf_i) ,设 (g_{10^{18}}equiv bpmod a) ,则 (l=1+a-b,r=10^{18}+a-b) 。因为:
[egin{aligned}sumlimits_{i=l}^rf_i&=g_r-g_{i-1}\&=g_{10^{18}+a-b}-g_{a-b}\&=g_{10^{18}}+(f_{10^{18}+1}-f_1)+cdots+(f_{10^{18}+a-b}-f_{a-b})\&=g_{10^{18}}+a-b\&equiv b+a-bpmod a\&equiv0pmod aend{aligned}
]
(忽略背景)
代码
#include<bits/stdc++.h>
#define ll long long
using namespace std;
ll l,r,a,INF=1e18;
int main(){
scanf("%lld",&a);
l=a-INF%a*9%a*9%a;
r=l+INF-1;
printf("%lld %lld
",l,r);
return 0;
}