0
1
mirror of https://git.sb/baoshuo/OI-codes.git synced 2024-11-30 19:16:28 +00:00
OI-codes/Luogu/P1898/P1898.cpp

33 lines
788 B
C++
Raw Normal View History

2020-11-18 13:05:55 +00:00
#include <bits/stdc++.h>
using namespace std;
string s;
2021-11-19 09:01:13 +00:00
int st, cnt = 0, a[1000005], ans[1000005];
2020-11-18 13:05:55 +00:00
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;
2021-11-19 09:01:13 +00:00
} else if ((ans[2] + ans[3]) % 10) {
2020-11-18 13:05:55 +00:00
cout << (ans[2] + ans[3]) % 10 << (ans[1] + ans[2]) % 10 << endl;
2021-11-19 09:01:13 +00:00
} else {
2020-11-18 13:05:55 +00:00
cout << (ans[1] + ans[2]) % 10 << endl;
}
return 0;
}