From 78704aba1ad971028fdddcb1f339fb356df56f15 Mon Sep 17 00:00:00 2001 From: Ren Baoshuo Date: Sun, 3 Jan 2021 10:59:10 +0800 Subject: [PATCH] =?UTF-8?q?P3197=20[HNOI2008]=E8=B6=8A=E7=8B=B1=20||=20#10?= =?UTF-8?q?196.=20=E3=80=8C=E4=B8=80=E6=9C=AC=E9=80=9A=206.1=20=E7=BB=83?= =?UTF-8?q?=E4=B9=A0=203=E3=80=8D=E8=B6=8A=E7=8B=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Luogu: R44562020 LibreOJ: https://loj.ac/s/1025675 --- LibreOJ/10196/10196.cpp | 23 +++++++++++++++++++++++ Luogu/problem/P3197/P3197.cpp | 23 +++++++++++++++++++++++ 2 files changed, 46 insertions(+) create mode 100644 LibreOJ/10196/10196.cpp create mode 100644 Luogu/problem/P3197/P3197.cpp diff --git a/LibreOJ/10196/10196.cpp b/LibreOJ/10196/10196.cpp new file mode 100644 index 00000000..e3d891cc --- /dev/null +++ b/LibreOJ/10196/10196.cpp @@ -0,0 +1,23 @@ +#include + +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; +} diff --git a/Luogu/problem/P3197/P3197.cpp b/Luogu/problem/P3197/P3197.cpp new file mode 100644 index 00000000..e3d891cc --- /dev/null +++ b/Luogu/problem/P3197/P3197.cpp @@ -0,0 +1,23 @@ +#include + +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; +}