样例可过
#include<bits/stdc++.h>
using namespace std;
int k,m,d,p1,p2;
int a[10000010],ans[10000010],cut[10000010];//ans存每一位,和一个字符串没区别
priority_queue<int,vector<int>,greater<int> > q;//小根堆放集合元素
int main()
{
cin>>k>>m;
q.push(1);
while(1)
{
int x=q.top();
d=0;
q.pop();
q.push(2*x+1);
q.push(4*x+5);
a[++p1]=x;//确保a数组单调递增
while(x)
{
d=d*10+x%10;
x/=10;
}//倒置
while(d)
{
ans[++p2]=d%10;//按位存,%10是取出个位
d/=10;
}
if(p1>=k)
break;
}
for(int i=1;i<=p1;i++)
{
printf("%d",a[i]);
}
printf("\n");
int cnt=0;
while(1)
{
for(int i=1;i<=p2;i++)
{
if(ans[i]<ans[i+1]&&!cut[i])
{
cut[i]=1;//被删去了,一会不输出就行
cnt++;
if(cnt>=m)
{
for(int j=1;j<=p2;j++)
{
if(!cut[j])
printf("%d",ans[j]);
}
return 0;
}
}
}
}
return 0;
}