mirror of
https://git.sb/baoshuo/OI-codes.git
synced 2024-12-05 02:26:26 +00:00
32 lines
645 B
C++
32 lines
645 B
C++
#include <bits/stdc++.h>
|
|
|
|
using namespace std;
|
|
|
|
int main() {
|
|
int m, s, a[15], ans1 = 0;
|
|
string x, ans2;
|
|
map<int, int> m1, m2;
|
|
cin >> m;
|
|
for (int i = 0; i < m; i++) {
|
|
cin >> a[i];
|
|
}
|
|
sort(a, a + m);
|
|
for (int i = 0; i < m; i++) {
|
|
m1[i] = a[i];
|
|
m2[a[i]] = i;
|
|
}
|
|
cin >> x >> s;
|
|
reverse(x.begin(), x.end());
|
|
for (int i = 0; i < x.size(); i++) {
|
|
ans1 += m2[x[i] - '0'] * pow(m, i);
|
|
}
|
|
while (s) {
|
|
ans2.push_back(m1[s % m] + '0');
|
|
s /= m;
|
|
}
|
|
reverse(ans2.begin(), ans2.end());
|
|
cout << ans1 << endl
|
|
<< ans2 << endl;
|
|
return 0;
|
|
}
|