0
1
mirror of https://git.sb/baoshuo/OI-codes.git synced 2024-11-10 12:18:48 +00:00
OI-codes/LibreOJ/2608/data/std.cpp

43 lines
776 B
C++
Raw Normal View History

2022-05-28 12:25:28 +00:00
#include <cstdio>
#include <ctime>
#include <cstdlib>
#include <iostream>
using namespace std;
long long n, m, k, x;
long long remainder;
long long Power(long long x, long long y, long long k)
{
long long result = 1;
remainder = x % k;
while(y > 0)
{
if(y % 2 == 1)
result = (result * remainder) % k;
remainder = (remainder * remainder) % k;
y = y / 2;
}
return result;
}
int main(void)
{
// freopen("circle.in", "r", stdin);
// freopen("circle.out", "w", stdout);
scanf("%lld%lld%lld%lld", &n, &m, &k, &x);
long long result = Power(10, k, n);
result = (result * m + x) % n;
printf("%lld\n", result);
return 0;
}