- C20250089's blog
A1617 转圈游戏
- 2023-3-15 15:04:06 @
#include<bits/stdc++.h>
using namespace std;
long long ksm(long long a,long long n,long long c){
if(n==0) return 1;
long long ff=ksm(10,n/2,c);
if(n%2==0) return ff*ff%c;
return ff*ff%c*10%c;
}
long long f(long long n,long long m,long long k,long long x){
long long y=ksm(10,k,n)*m%n;
return (x%n+y)%n;
}
int main(){
long long n,m,k,x;
cin>>n>>m>>k>>x;
cout<<f(n,m,k,x);
return 0;
}