From 87b094aca288e76e3ac26c1360e096338a7009cc Mon Sep 17 00:00:00 2001 From: Ren Baoshuo Date: Wed, 18 Nov 2020 21:05:55 +0800 Subject: [PATCH] =?UTF-8?q?P1898=20=E7=BC=98=E5=88=86=E8=AE=A1=E7=AE=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit R42134215 --- problem/P1898/P1898.cpp | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 problem/P1898/P1898.cpp diff --git a/problem/P1898/P1898.cpp b/problem/P1898/P1898.cpp new file mode 100644 index 00000000..0a6f2cf7 --- /dev/null +++ b/problem/P1898/P1898.cpp @@ -0,0 +1,34 @@ +#include + +using namespace std; + +string s; +int st, cnt = 0, a[1000005], ans[1000005]; + +int main() { + cin >> s >> st; + for (int i = 0; i < s.size(); i++) { + a[i] = s[i] - 'A' + st; + } + for (int i = s.size() - 1; i >= 0; i--) { + while (a[i] > 0) { + ans[++cnt] = a[i] % 10; + a[i] /= 10; + } + } + for (int i = cnt - 1; i >= 3; i--) { + for (int j = 1; j <= i; j++) { + ans[j] = (ans[j] + ans[j + 1]) % 10; + } + } + if (ans[3] == 1 && ans[2] == 0 && ans[1] == 0) { + cout << 100 << endl; + } + else if ((ans[2] + ans[3]) % 10) { + cout << (ans[2] + ans[3]) % 10 << (ans[1] + ans[2]) % 10 << endl; + } + else { + cout << (ans[1] + ans[2]) % 10 << endl; + } + return 0; +}