社区讨论
求助大佬
P1323删数问题参与者 1已保存回复 0
讨论操作
快速查看讨论及其快照的属性,并进行相关操作。
- 当前回复
- 0 条
- 当前快照
- 1 份
- 快照标识符
- @mi6mir4x
- 此快照首次捕获于
- 2025/11/20 07:18 4 个月前
- 此快照最后确认于
- 2025/11/20 07:18 4 个月前
CPP
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<vector>
#include<queue>
#include<stack>
#define maxa 30000+10
#define FOR(i,x,y) for(i=x;i<=y;++i)
using namespace std;
int a[maxa];
int main(){
int k,m;
priority_queue<int,vector<int>,greater<int> > q;
cin>>k>>m;
int t = 1;
q.push(1);
while(!q.empty()){
int u = q.top();
q.pop();
a[t++]=u;
if(t==maxa){
break;
}
q.push(2*u+1);
q.push(4*u+5);
}
string s;
int i;
stack<int > st;
FOR(i,1,k){
cout<<a[i];
while(a[i]>0){
st.push(a[i]%10);
a[i]/=10;
}
while(!st.empty()){
s+=st.top()+'0';
st.pop();
}
}
cout<<endl;
int tot = 0;
while(tot<m){
for(i=0;i<s.length();++i){
if((i+1)<s.length()&&s[i]<s[i+1]){
s.erase(i,1);
break;
}
if(i==s.length()){
s.erase(s.length()-1,1);
}
tot++;
}
}
if(s.length()){
cout<<s<<endl;
}
else{
cout<<0<<endl;
}
}
回复
共 0 条回复,欢迎继续交流。
正在加载回复...