求 $(x+m*10^{k})\%n$
显然的快速幂。
![](https://images.cnblogs.com/OutliningIndicators/ContractedBlock.gif)
1 #include<iostream> 2 #include<cstdio> 3 #include<cstring> 4 #define re register 5 using namespace std; 6 typedef long long ll; 7 ll n,m,X,k; 8 ll ksm(ll x,ll y){ 9 ll res=1; 10 for(;y;y>>=1){ 11 if(y&1)res=res*x%n; 12 x=x*x%n; 13 }return res; 14 } 15 int main(){ 16 scanf("%lld%lld%lld%lld",&n,&m,&k,&X); 17 printf("%lld",(X+m*ksm(10,k)%n)%n); 18 return 0; 19 }