标签:
http://acm.hdu.edu.cn/showproblem.php?pid=3183
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 2556 Accepted Submission(s): 999
#include<stdio.h> #include<math.h> #include<string.h> #include<stdlib.h> #include<algorithm> using namespace std; typedef long long ll; const int N = 1010; int main() { char s[N]; int a[N], str[N]; int m, i; while(~scanf("%s%d", s, &m)) { memset(str, 0, sizeof(str)); int k = 0, l = strlen(s); for(i = 0 ; s[i] != ‘\0‘ ; i++) a[i] = s[i] - ‘0‘; for(i = 0 ; i < l && m > 0; i++) { if(a[i] <= a[i + 1]) str[k++] = a[i]; else { m--; while(str[k - 1] > a[i + 1] && m > 0 && k >= 1) { m--; k--; } } } for(; i < l ; i++) str[k++] = a[i]; for(i = 0 ; i < k - m ; i++) if(str[i] != 0) break; if(i == k - m) printf("0"); else { for(int j = i ; j < k - m ; j++) printf("%d", str[j]); } printf("\n"); } return 0; }
标签:
原文地址:http://www.cnblogs.com/qq2424260747/p/4977269.html