0
1
mirror of https://git.sb/baoshuo/OI-codes.git synced 2024-11-09 23:18:47 +00:00

P1965 [NOIP2013 提高组] 转圈游戏 || #2608. 「NOIP2013」转圈游戏

R44561025
https://loj.ac/s/1025658
This commit is contained in:
Baoshuo Ren 2021-01-03 10:46:55 +08:00 committed by Baoshuo Ren
parent 85c12c8df7
commit ab92882002
Signed by: baoshuo
GPG Key ID: 70F90A673FB1AB68
2 changed files with 42 additions and 0 deletions

21
LibreOJ/2608/2608.cpp Normal file
View File

@ -0,0 +1,21 @@
#include <bits/stdc++.h>
using namespace std;
long long binpow(long long a, long long b, long long m) {
a %= m;
long long res = 1;
while (b > 0) {
if (b & 1) res = res * a % m;
a = a * a % m;
b >>= 1;
}
return res;
}
int main() {
int n, m, k, x;
cin >> n >> m >> k >> x;
cout << (x % n + m % n * binpow(10, k, n) % n) % n << endl;
return 0;
}

View File

@ -0,0 +1,21 @@
#include <bits/stdc++.h>
using namespace std;
long long binpow(long long a, long long b, long long m) {
a %= m;
long long res = 1;
while (b > 0) {
if (b & 1) res = res * a % m;
a = a * a % m;
b >>= 1;
}
return res;
}
int main() {
int n, m, k, x;
cin >> n >> m >> k >> x;
cout << (x % n + m % n * binpow(10, k, n) % n) % n << endl;
return 0;
}