Simple Math ARC111 - A 数论,思维
Simple Math ARC111 - A 数论,思维
题意
给出\(N,M\),求\(\lfloor\frac{10^N}{M}\rfloor\)除以\(M\)的余数
\[1\leq N \leq 10^{18}\\
1\leq M \leq 10000
\]
分析
\(\lfloor\frac{10^N}{M}\rfloor \equiv \lfloor\frac{10^N}{M}\rfloor - kM \equiv \lfloor\frac{10^N - kM^2}{M}\rfloor (mod M)\)
于是先求分子即可
代码
int main(){
ll n = rd();
ll m = rd();
cout << ksm(10,n,m * m) / m;
}