luogu P1965 题目
#include#include #include #include #include #include #include #include #include #include #define rg register#define lst long long#define Nusing namespace std;lst n,m,k,x,ans;//(10^k%n*m%n+x)%ninline lst read(){ rg lst s=0,m=1;rg char ch=getchar(); while(ch!='-'&&(ch<'0'||ch>'9'))ch=getchar(); if(ch=='-')m=-1,ch=getchar(); while(ch>='0'&&ch<='9')s=(s<<3)+(s<<1)+ch-'0',ch=getchar(); return s*m;}inline lst qpow(rg lst a,rg lst b){ rg lst base=a,res=1; while(b) { if(b&1)res=(res*base)%n; base=(base*base)%n; b>>=1; } return res;}int main(){ n=read(),m=read(),k=read(),x=read(); ans=qpow(10,k); ans=(ans*m)%n; ans=(ans+x)%n; printf("%lld\n",ans); return 0;}