建议降级
查看原帖
建议降级
1018403
Novelist_楼主2024/8/13 13:09

模拟赛上快速做出了,建议降级。

#include<bits/stdc++.h>
using namespace std;
string a,b;
bool p[4];
int len;
int main()
{
//  freopen("tri.in","r",stdin);
//  freopen("tri.out","w",stdout);
  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;
}
2024/8/13 13:09
加载中...