标签:
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 3019 Accepted Submission(s): 1172
1 #include<iostream> 2 #include<algorithm> 3 #include<queue> 4 #include<stack> 5 #include<map> 6 #include<cstring> 7 #include<cstdio> 8 #include<vector> 9 #define ll __int64 10 using namespace std; 11 char a[1005]; 12 vector<int> ve; 13 int flag; 14 int n; 15 int main() 16 { 17 memset(a,0,sizeof(a)); 18 while(cin>>a>>n) 19 { 20 int len; 21 len=strlen(a); 22 if(len<=n) 23 cout<<"0"<<endl; 24 else 25 { 26 ve.clear(); 27 for(int i=0;i<len;i++) 28 ve.push_back(a[i]-‘0‘); 29 while(n--) 30 { 31 int flag=1; 32 for(int i=0;i<ve.size()-1;i++) 33 { 34 if(ve[i]>ve[i+1]) 35 { 36 flag=0; 37 ve.erase(ve.begin()+i); 38 break; 39 } 40 } 41 if(flag) 42 { 43 ve.erase(ve.end()-1); 44 } 45 } 46 flag=1; 47 for(int i=0;i<ve.size();i++) 48 { 49 if(ve[i]==0&&flag) 50 continue; 51 else 52 { 53 flag=0; 54 cout<<ve[i]; 55 } 56 } 57 if(flag) 58 cout<<"0"; 59 cout<<endl; 60 } 61 memset(a,0,sizeof(a)); 62 } 63 return 0; 64 }
标签:
原文地址:http://www.cnblogs.com/hsd-/p/5397328.html