0分,样例过了,求调!
查看原帖
0分,样例过了,求调!
802297
hblhuangbolun楼主2024/6/15 15:36

题目传送门

#include<bits/stdc++.h>

using namespace std;
priority_queue <int,vector<int>,greater<int> >q;

string st="";

int main()
{
	int k,m;
	cin>>k>>m;
	q.push(1);
	
	for(int i=1; i<=k; i++)
	{
		int p=q.top();
		int x=p,o=0;
		if(p>=10)
		{
			while(p!=0)
			{
				o=o*10+p%10;
				p/=10;
			}
			while(o!=0)
			{
				st+=(o%10+'0');
				o/=10;
			}
		}
		else st+=(x+'0');
		q.pop();
		q.push(2*x+1);
		q.push(4*x+5);  
	}
	
	cout<<st<<endl;
	
	int len=st.length(),sum=0;
	while(1)
	{
		for(int i=0; i<len-1; i++)
		{
			if(st[i]<st[i+1])
			{
				st.erase(i,1);
				sum++;
				if(sum>=m)
				{
					cout<<st;
					return 0;
				}
			}
		}
	}
	
}
2024/6/15 15:36
加载中...