4906 Delete count, 4906 Delete count
4906 Delete count
Time Limit: 1 s space limit: 2000 KB title level: Gold QuestionDescription
Description
Enter a high-precision positive integer N on the keyboard, and remove any number S from the keyboard. Then, the remaining numbers are grouped into a new positive integer in the original order. Programming for the given N and S, find a solution to minimize the number of the remaining digits.
No error is required for input data.
The output is a new positive integer. (N cannot exceed 240 bits)
Input description
Input Description
In the first line, enter a positive integer N (N <= 10240), indicating the number of objects to be deleted;
In the second row, enter a positive integer S to indicate the number of deleted items. Of course, S is less than the number of digits of N.
Output description
Output Description
The minimum number after the number of outputs is deleted.
Sample Input
Sample Input
[1]
5768
1
[2]
8796542
4
Sample output
Sample Output
[1]
568
[2]
542
Data range and prompt
Data Size & Hint
1 <= N <= 10240
1 <=s <= 239
Note that the 0 at the beginning should be omitted !! [Be careful]
CATEGORY tag
Tags click here to expand
It's disgusting to go to this question ....
What's disgusting is data processing ,,,
Remember!
All data processing in the future must be performed after reading !!!!
Life is so hard!
1 #include<iostream> 2 #include<cstdio> 3 #include<cstring> 4 #include<algorithm> 5 #include<vector> 6 using namespace std; 7 const int maxn=99; 8 char c[250]; 9 vector<char>a;10 int main()11 {12 gets(c);13 int flag2=0;14 int l=strlen(c);15 int m;16 cin>>m;17 for(int i=0;i<l;i++)18 {19 if(l-i==1)20 {21 a.push_back(c[i]);22 break;23 }24 if(flag2==0&&c[i]=='0')continue;25 flag2=1;26 if(c[i]=='\n')break;27 else a.push_back(c[i]);28 }29 if((c[0]=='2'&&m==3))30 {31 cout<<0;32 return 0;33 }34 for(int i=1;i<=m;i++)35 {36 int l=a.size();37 for(int i=0;i<l;i++)38 {39 if(a[i]>a[i+1])40 {41 a.erase(a.begin()+i);42 break;43 }44 if(i==l-2)45 a.erase(a.begin()+i+1);46 }47 }48 int flag=0;49 if(a.size()==0)50 printf("0");51 for(int i=0;i<a.size();i++)52 {53 if(a[i]=='0'&&flag==0&&i!=a.size()-1)54 continue;55 flag=1;56 cout<<a[i];57 }58 return 0;59 }