From 70fa859aa81643013d2a45ce54e4a7fa468e4a79 Mon Sep 17 00:00:00 2001 From: Ren Baoshuo Date: Wed, 30 Jun 2021 16:25:38 +0800 Subject: [PATCH] =?UTF-8?q?#162.=20=E5=BF=AB=E9=80=9F=E5=B9=82=202?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit https://loj.ac/s/1169057 --- LibreOJ/162/162.cpp | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 LibreOJ/162/162.cpp diff --git a/LibreOJ/162/162.cpp b/LibreOJ/162/162.cpp new file mode 100644 index 00000000..3347b20e --- /dev/null +++ b/LibreOJ/162/162.cpp @@ -0,0 +1,42 @@ +#include + +using namespace std; + +const long long m = 998244352; + +int read() { + int x = 0, w = 1; + char c; + while (!isdigit(c)) { + if (c == '-') w = -1; + c = getchar(); + } + while (isdigit(c)) { + x = x * 10 + (c - '0'); + c = getchar(); + } + return x * w; +} + +long long binpow(long long a, long long b) { + 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() { + long long x, n, a; + x = read(); + n = read(); + for (int i = 0; i < n; i++) { + a = read(); + printf("%lld ", binpow(x, a)); + } + printf("\n"); + return 0; +}