程序一运行就停止工作,调试是在int main()出了问题,求原因:
#include<bits/stdc++.h>
using namespace std;
int main()
{
int k,m,n,h,t,a[30001],x,i,num;
bool b[4300000]={false};
string s;
cin>>k>>m;
a[1]=1;
b[1]=true;
while (t<4300000)
{
h++;
if (a[h]*2+1<4300000) { t++; a[t]=a[h]*2+1; b[a[t]]=true; }
if (a[h]*4+5<4300000) { t++; a[t]=a[h]*4+5; b[a[t]]=true; }
}
x=1;
s="1";
k--;
while (k>0)
{
for (int i=x+1;i<=4300000;i++)
if (b[i]) break;
else x++;
k--;
num=x;
cout<<x;
}
cout<<s<<endl;
n=s.size();
while (m>0)
{
i=0;
while (s[i]>=s[i+1] && i<n-1)
i++;
s.erase(s.begin()+i);
m--;
}
while (s[0]=='0')
s=s.substr(1);
cout<<s;
return 0;
}