题解:CF2168A2 Encode and Decode (Hard Version)
注意到
所以我们用
代码:
#include <bits/stdc++.h>
#define int long long
using namespace std;
string get(int x)
{
stack <int> st;
for (int i = 0; i < 10; i ++)
{
st.push(x % 10);
x /= 10;
}
string s;
while (!st.empty())
{
s.push_back(st.top() + 'a');
st.pop();
}
return s;
}
void sol1()
{
int n;
cin >> n;
string s;
for (int i = 1; i <= n; i ++)
{
int x;
cin >> x;
s += get(x);
}
cout << s << endl;
}
void sol2()
{
string s;
cin >> s;
cout << s.size() / 10 << endl;
for (int i = 0; i < s.size(); i += 10)
{
int ret = 0;
for (int j = 0; j < 10; j ++)
ret = ret * 10 + s[i + j] - 'a';
cout << ret << " ";
}
cout << endl;
}
signed main()
{
cin.tie(0)->sync_with_stdio(0);
string s;
cin >> s;
if (s == "first")
sol1();
else
sol2();
return 0;
}