From 5c4e71b2c036821b371aa99ef3872d8bb2e8fc02 Mon Sep 17 00:00:00 2001 From: Ren Baoshuo Date: Thu, 19 Aug 2021 22:13:01 +0800 Subject: [PATCH] =?UTF-8?q?875.=20=E5=BF=AB=E9=80=9F=E5=B9=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit https://www.acwing.com/problem/content/submission/code_detail/7249810/ --- AcWing/875/875.cpp | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 AcWing/875/875.cpp diff --git a/AcWing/875/875.cpp b/AcWing/875/875.cpp new file mode 100644 index 00000000..c2a6ba6e --- /dev/null +++ b/AcWing/875/875.cpp @@ -0,0 +1,25 @@ +#include + +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; + cin >> n; + while (n--) { + long long a, b, p; + cin >> a >> b >> p; + cout << binpow(a, b, p) << endl; + } + return 0; +}