记录编号 421544 评测结果 AAAAAAAAAA
题目名称 [NOIP 1994]删数问题 最终得分 100
用户昵称 GravatarHeHe 是否通过 通过
代码语言 C++ 运行时间 0.002 s
提交时间 2017-07-07 11:39:59 内存使用 0.56 MiB
显示代码纯文本
#include <iostream>
#include <cstdio>
#include <cstring>
using namespace std;

const int MAXN = 300;

inline char getc(void){ 
    static char buf[1 << 18], *fs, *ft;
    return (fs == ft && (ft = (fs = buf) + fread(buf, 1, 1 << 18, stdin)), fs == ft) ? EOF : *fs++;
}

inline int in(void){ 
    register char tmp = getc();
    register int res = 0;
    while(!isdigit(tmp)) tmp = getc();
    while(isdigit(tmp))
        res = (res + (res << 2) << 1) + (tmp ^ 48),
        tmp = getc();
    return res;
}

inline int get_len(char *s){ 
    register int len = 0;
    register char tmp = getc();
    while(!isdigit(tmp)) tmp = getc();
    while(isdigit(tmp))
        *(s++) = tmp, ++len, 
        tmp = getc();
    return len;
}

int len, N;
char s[MAXN];

int main(){ 
#ifndef LOCAL
    freopen("delmin.in", "r", stdin);
    freopen("delmin.out", "w", stdout);
#endif
    len = get_len(s);
    N = in();
    if(len <= N) return 0;
    bool flag;
    for(int i = 1; i <= N; ++i){ 
        flag = true;
        for(int j = 0; j < len; ++j){ 
            if(!s[j]) continue;
            int k = j + 1;
            while(!s[k] && k < len) ++k;
            if(k == len){ 
                len = j, flag = false;
            } else if(s[k] < s[j]){ 
                s[j] = 0, flag = false;
            }
            if(!flag) break ;
        }
    }
    int i = 0;
    while(i < len && (s[i] == '0' || s[i] == '\0')){ 
        ++i;
        if(i == len){ 
            putchar('0');
            return 0;
        }
    }

    for(; i < len; ++i){ 
        if(s[i]) putchar(s[i]);
    }
    return 0;
}