模拟赛上快速做出了,建议降级。
#include<bits/stdc++.h>
using namespace std;
string a,b;
bool p[4];
int len;
int main()
{
ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
cin>>a;
len=a.size();
if(a[len-1]=='4')
{
a[len-1]='1';
cout<<a+'\n';
a[len-1]='2';
cout<<a+'\n';
a[len-1]='3';
cout<<a;
return 0;
}
for(int i=len-1;i>=1;--i)
{
if(!p[a[i]-'0'])
{
b=a;
b.erase(i,len-i);
cout<<b+'4'<<'\n';
p[a[i]-'0']=1;
}
}
return 0;
}