题目
代码
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll n,m,k,x;
inline ll quick_pow(ll a,ll b)
{
ll ans=1;
for( ;b;b>>=1)
{
if(b&1) ans=ans*a%n;
a=a*a%n;
}
return ans;
}
int main()
{
scanf("%lld%lld%lld%lld",&n,&m,&k,&x);
ll ans=(x+m*quick_pow(10,k)%n)%n;
printf("%lld\n",ans);
return 0;
}