mirror of
https://git.sb/baoshuo/OI-codes.git
synced 2024-12-28 14:31:58 +00:00
P1965 [NOIP2013 提高组] 转圈游戏 || #2608. 「NOIP2013」转圈游戏
R44561025 https://loj.ac/s/1025658
This commit is contained in:
parent
85c12c8df7
commit
ab92882002
21
LibreOJ/2608/2608.cpp
Normal file
21
LibreOJ/2608/2608.cpp
Normal 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;
|
||||
}
|
21
Luogu/problem/P1965/P1965.cpp
Normal file
21
Luogu/problem/P1965/P1965.cpp
Normal 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;
|
||||
}
|
Loading…
Reference in New Issue
Block a user