CF468C Hack it!
作者:互联网
- 题面:定义函数\(f(x)=x\)的各个数位之和。请构造出一组\(L,R\)满足\(1 \le L \le R \le 10^{200}\),同时\(\sum _ {i=L} ^{R} f_{(i)} \mod a =0 \enspace (1\le a \le 10^{18})\)
题解
有一个很显然的式子:\(f(i+10^{18})=f(i)+1\)
令\(\sum_{i=1}^{i=10^{18}}=A(\mod a)\)
则\(\sum_{i=2}^{i=10^{18}+1}f(i)=A+1(\mod a)\)
……
可得\(\sum_{i=t}^{i=10^{18}+t-1}f(i)=A+t(\mod a)\)
则\(\sum_{i=a-A}^{i=10^{18}+a-A-1}f(i)=A+a-A(\mod a)\)
解得\(L=a-A,r=10^{18}+a-A-1\)
解\(A=\sum_{i=1}^{i=10^{18}}f(i)=18 \times \frac{(1+9) \times 9}{2} \times 10^{18-1}=18\times 45 \times 10^{17}=81 \times 10^{18}\)
Code
\[\mathcal{show \enspace you \enspace the \enspace code} \]
const LL INF=1e18;
LL mod;LL L,R;
int main(){
scanf("%lld",&mod);
L=mod-INF%mod*81%mod;
R=L+INF-1;
printf("%lld %lld",L,R);
return 0;
}
标签:10,le,CF468C,18,sum,times,Hack,mod 来源: https://www.cnblogs.com/wuchen-place/p/15359742.html