63 lines
773 B
C++
63 lines
773 B
C++
#include<cstdio>
|
|
#include<cstring>
|
|
using namespace std;
|
|
const int N=1005;
|
|
char s[N];
|
|
int a[N];
|
|
int main()
|
|
{
|
|
int n;
|
|
while(~scanf("%s%d",&s,&n))
|
|
{
|
|
int len=strlen(s);
|
|
for(int i=0; i<len; i++)
|
|
{
|
|
a[len-i]=s[i]-'0';
|
|
}
|
|
while(n--)
|
|
{
|
|
for(int i=len; i>0; i--)
|
|
{
|
|
while(a[i]==-1)
|
|
{
|
|
i--;
|
|
}
|
|
int j=i-1;
|
|
while(a[j]==-1)
|
|
{
|
|
j--;
|
|
}
|
|
if(a[i]>a[j])
|
|
{
|
|
a[i]=-1;
|
|
// printf("%d:%d,%d\n",n,i,j);
|
|
break;//
|
|
}
|
|
}
|
|
}
|
|
// for(int i=len; i>0; i--)
|
|
// {
|
|
// printf("%d",a[i]);
|
|
// }
|
|
// printf("\n");
|
|
while(a[len]<=0)//<= -> ,
|
|
{
|
|
len--;
|
|
}
|
|
bool tag=0;
|
|
for(int i=len; i>0; i--)
|
|
{
|
|
if(a[i]!=-1)
|
|
{
|
|
tag=1;
|
|
printf("%d",a[i]);
|
|
}
|
|
}
|
|
if(tag==0)
|
|
{
|
|
printf("0");
|
|
}
|
|
printf("\n");
|
|
}
|
|
}
|