0
1
mirror of https://git.sb/baoshuo/OI-codes.git synced 2024-12-24 03:31:59 +00:00

P3197 [HNOI2008]越狱 || #10196. 「一本通 6.1 练习 3」越狱

Luogu: R44562020
LibreOJ: https://loj.ac/s/1025675
This commit is contained in:
Baoshuo Ren 2021-01-03 10:59:10 +08:00 committed by Baoshuo Ren
parent ab92882002
commit 78704aba1a
Signed by: baoshuo
GPG Key ID: 70F90A673FB1AB68
2 changed files with 46 additions and 0 deletions

23
LibreOJ/10196/10196.cpp Normal file
View 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;
}

View 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;
}