From ab92882002a8d1d8ed706baf4f97f0746d86024f Mon Sep 17 00:00:00 2001 From: Ren Baoshuo Date: Sun, 3 Jan 2021 10:46:55 +0800 Subject: [PATCH] =?UTF-8?q?P1965=20[NOIP2013=20=E6=8F=90=E9=AB=98=E7=BB=84?= =?UTF-8?q?]=20=E8=BD=AC=E5=9C=88=E6=B8=B8=E6=88=8F=20||=20#2608.=20?= =?UTF-8?q?=E3=80=8CNOIP2013=E3=80=8D=E8=BD=AC=E5=9C=88=E6=B8=B8=E6=88=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit R44561025 https://loj.ac/s/1025658 --- LibreOJ/2608/2608.cpp | 21 +++++++++++++++++++++ Luogu/problem/P1965/P1965.cpp | 21 +++++++++++++++++++++ 2 files changed, 42 insertions(+) create mode 100644 LibreOJ/2608/2608.cpp create mode 100644 Luogu/problem/P1965/P1965.cpp diff --git a/LibreOJ/2608/2608.cpp b/LibreOJ/2608/2608.cpp new file mode 100644 index 00000000..62f58679 --- /dev/null +++ b/LibreOJ/2608/2608.cpp @@ -0,0 +1,21 @@ +#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, m, k, x; + cin >> n >> m >> k >> x; + cout << (x % n + m % n * binpow(10, k, n) % n) % n << endl; + return 0; +} diff --git a/Luogu/problem/P1965/P1965.cpp b/Luogu/problem/P1965/P1965.cpp new file mode 100644 index 00000000..62f58679 --- /dev/null +++ b/Luogu/problem/P1965/P1965.cpp @@ -0,0 +1,21 @@ +#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, m, k, x; + cin >> n >> m >> k >> x; + cout << (x % n + m % n * binpow(10, k, n) % n) % n << endl; + return 0; +}