mirror of
https://git.sb/baoshuo/OI-codes.git
synced 2024-11-23 19:28:48 +00:00
P3197 [HNOI2008]越狱 || #10196. 「一本通 6.1 练习 3」越狱
Luogu: R44562020 LibreOJ: https://loj.ac/s/1025675
This commit is contained in:
parent
ab92882002
commit
78704aba1a
23
LibreOJ/10196/10196.cpp
Normal file
23
LibreOJ/10196/10196.cpp
Normal file
@ -0,0 +1,23 @@
|
||||
#include <bits/stdc++.h>
|
||||
|
||||
using namespace std;
|
||||
|
||||
const int mod = 100003;
|
||||
|
||||
long long binpow(long long a, long long b) {
|
||||
a %= mod;
|
||||
long long res = 1;
|
||||
while (b > 0) {
|
||||
if (b & 1) res = res * a % mod;
|
||||
a = a * a % mod;
|
||||
b >>= 1;
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
int main() {
|
||||
long long m, n;
|
||||
cin >> m >> n;
|
||||
cout << (binpow(m, n) - binpow(m - 1, n - 1) * m % mod + mod) % mod << endl;
|
||||
return 0;
|
||||
}
|
23
Luogu/problem/P3197/P3197.cpp
Normal file
23
Luogu/problem/P3197/P3197.cpp
Normal file
@ -0,0 +1,23 @@
|
||||
#include <bits/stdc++.h>
|
||||
|
||||
using namespace std;
|
||||
|
||||
const int mod = 100003;
|
||||
|
||||
long long binpow(long long a, long long b) {
|
||||
a %= mod;
|
||||
long long res = 1;
|
||||
while (b > 0) {
|
||||
if (b & 1) res = res * a % mod;
|
||||
a = a * a % mod;
|
||||
b >>= 1;
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
int main() {
|
||||
long long m, n;
|
||||
cin >> m >> n;
|
||||
cout << (binpow(m, n) - binpow(m - 1, n - 1) * m % mod + mod) % mod << endl;
|
||||
return 0;
|
||||
}
|
Loading…
Reference in New Issue
Block a user