标签:show orm lead space 数字 div should des let
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=3183
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)
#include <cstdio> #include <algorithm> #include <cstring> using namespace std; const int mac=1e3+10; char s[mac]; void solve(char *s,int pos,int n) { for (int i=pos; i<n; i++) s[i]=s[i+1]; } int main() { int m,n; while (~scanf("%s",s)){ scanf("%d",&m); n=strlen(s); for (int i=0; i<n-1; i++){ if (!m) break; while (s[i]>s[i+1] && m) solve(s,i,n--),m--,i--; } while (m){ m--;s[--n]=‘\0‘; } int len=strlen(s); int i=0; while(s[i]==‘0‘) i++; for (int j=i; j<len; j++) printf("%c",s[j]); if (i==len) printf("0"); printf("\n"); } return 0; }
HDU-3183 A Magic Lamp--贪心+暴力数组移动
标签:show orm lead space 数字 div should des let
原文地址:https://www.cnblogs.com/lonely-wind-/p/12196055.html