mirror of
https://git.sb/baoshuo/OI-codes.git
synced 2024-11-10 11:58:48 +00:00
36 lines
742 B (Stored with Git LFS)
C++
36 lines
742 B (Stored with Git LFS)
C++
#include <cstdio>
|
|
#include <iostream>
|
|
#include <cstdlib>
|
|
#include <ctime>
|
|
|
|
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;
|
|
}
|