From 56435b1c0a92928cfa3efe3278072415e17a593e Mon Sep 17 00:00:00 2001 From: Baoshuo Date: Wed, 11 May 2022 17:21:19 +0800 Subject: [PATCH] =?UTF-8?q?1008.=20[HNOI2008]=E8=B6=8A=E7=8B=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit https://darkbzoj.cc/submission/191426 --- BZOJ/1008/1008.cpp | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 BZOJ/1008/1008.cpp diff --git a/BZOJ/1008/1008.cpp b/BZOJ/1008/1008.cpp new file mode 100644 index 00000000..cced343c --- /dev/null +++ b/BZOJ/1008/1008.cpp @@ -0,0 +1,25 @@ +#pragma GCC optimize("Ofast") + +#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; +}