121 条题解

  • 1
    @ 2018-01-18 22:43:40

    此题奇坑!!!
    1.只有0,要输0
    2.不只有0,要删0
    3.全是0,要输0
    4.删光了,要输0

    #include <cstdio>
    #include <cstdlib>
    #include <iostream>
    #include <cstring>
    #include <algorithm>
    using namespace std;
    char zjy[1000]={0};
    int n;
    int main()
    {
        scanf("%s%d",zjy,&n);
        int lo=strlen(zjy);
        if(lo==n)
        {
            printf("0");
            return 0;
        }
        for(int i=1;i<=n;i++)
        {
            for(int j=0;j<lo-1;j++)
            {
                if(zjy[j]>zjy[j+1])
                {
                    for(int k=j;k<lo-1;k++)
                        zjy[k]=zjy[k+1];
                    break;
                }
            }
            lo--;
        }
        bool flag=false;
        int e=1;
        for(int i=0;i<lo;i++)
        {
            if(zjy[i]!='0')
                flag=true,e=0;
            if(flag)
                printf("%c",zjy[i]);
        }
        if(e)
            printf("0");
        return 0;
    }
    
  • 0
    @ 2017-04-04 14:09:55
    #include <iostream>
    #include <cstdio>
    #include <string>
    using namespace std;
    int main() {
        //freopen("birthday.in","r",stdin);
        //freopen("birthday.out","w",stdout);
        ios :: sync_with_stdio(false);
        string str;
        int k;
        cin >> str >> k;
        for (int Case = 1;Case <= k;Case++) {
            unsigned pos = 0;
            while (pos < str.length() && str[pos] <= str[pos+1]) pos++;
            for (unsigned i = pos+1;i < str.length();i++) str[i-1] = str[i];
        }
        unsigned begin = 0;
        while (!(str[begin]-'0')) begin++;
        for (unsigned i = begin;i < str.length()-k;i++) printf("%c",str[i]);
        if (begin >= str.length()-k) printf("0");
        return 0;
    }
    
  • 0
    @ 2015-08-26 17:22:49

    #include<iostream>
    #include<cstdio>
    #include<cstring>
    using namespace std;
    int main()
    {
    freopen("delete.in","r",stdin);
    freopen("delete.out","w",stdout);
    int i,lena,j,n,k;
    char a[241];
    bool b;
    scanf("%s%d",a,&n);
    lena=strlen(a);
    for(k=1;k<=n;k++){
    b=0;
    for(i=0;i<lena-1;i++){
    if(a[i]>a[i+1]){
    for(j=i;j<lena-1;j++){
    a[j]=a[j+1];
    }
    lena--;
    b=1;
    break;
    }
    }
    if(!b){
    lena--;
    }
    }
    i=0;
    while(i<lena){
    if(a[i]=='0'){
    i++;
    }
    else{
    break;
    }
    }
    if(i==lena){
    printf("0");
    return 0;
    }
    for(j=i;j<lena;j++){
    printf("%c",a[j]);
    }
    return 0;
    }

  • 0
    @ 2015-08-26 17:22:19

    #include<iostream>
    #include<cstdio>
    #include<cstring>
    using namespace std;
    int main()
    {
    int i,lena,j,n,k;
    char a[241];
    bool b;
    scanf("%s%d",a,&n);
    lena=strlen(a);
    for(k=1;k<=n;k++){
    b=0;
    for(i=0;i<lena-1;i++){
    if(a[i]>a[i+1]){
    for(j=i;j<lena-1;j++){
    a[j]=a[j+1];
    }
    lena--;
    b=1;
    break;
    }
    }
    if(!b){
    lena--;
    }
    }
    i=0;
    while(i<lena){
    if(a[i]=='0'){
    i++;
    }
    else{
    break;
    }
    }
    if(i==lena){
    printf("0");
    return 0;
    }
    for(j=i;j<lena;j++){
    printf("%c",a[j]);
    }
    return 0;
    }

  • 0
    @ 2014-02-09 13:48:10

    var s,i:longint;
    n:string;
    begin
    readln(n);
    readln(s);
    while s>0 do
    begin
    i:=1;
    while (i<length(n)) and (n[i]<=n[i+1]) do
    i:=i+1;
    delete(n,i,1);
    s:=s-1;
    end;
    while (length(n)>1) and (n[1]='0') do delete(n,1,1);
    writeln(n);
    end.

  • 0
    @ 2013-11-04 13:41:02

    测试数据 #0: Accepted, time = 0 ms, mem = 468 KiB, score = 10

    测试数据 #1: Accepted, time = 23 ms, mem = 468 KiB, score = 10

    测试数据 #2: Accepted, time = 0 ms, mem = 464 KiB, score = 10

    测试数据 #3: Accepted, time = 0 ms, mem = 464 KiB, score = 10

    测试数据 #4: Accepted, time = 0 ms, mem = 468 KiB, score = 10

    测试数据 #5: Accepted, time = 0 ms, mem = 468 KiB, score = 10

    测试数据 #6: Accepted, time = 0 ms, mem = 468 KiB, score = 10

    测试数据 #7: Accepted, time = 0 ms, mem = 464 KiB, score = 10

    测试数据 #8: Accepted, time = 0 ms, mem = 460 KiB, score = 10

    测试数据 #9: Accepted, time = 0 ms, mem = 464 KiB, score = 10

    Accepted, time = 23 ms, mem = 468 KiB, score = 100

    尼玛,,,0也算在内。。。。。。
    0开头就忽略。。。。。
    只有0又要输出。。。。。
    #include<cstdio>
    #include<cstdlib>
    #include<cstring>
    using namespace std;
    int main(){
    int k,n,i;
    char num[1010];
    gets(num);n=strlen(num);
    scanf("%d",&k);
    if(n==k) {printf("0");return 0;}
    for(i=1;i<=k;i++){
    int q,t=-20;

    for(q=0;q<=n;q++){
    if(t<=num[q]-'0') t=num[q]-'0';
    else {
    for(int w=q-1;w<=n;w++) num[w]=num[w+1];
    n--;
    break;
    }
    }
    if(t<1) n--;
    }
    for(i=0;i<n;i++) if(num[i]-'0'>0) break;
    if(i<=n-1) for(;i<n;i++) printf("%c",num[i]);
    else {printf("0");return 0;}
    return 0;
    }

  • 0
    @ 2013-11-01 23:24:37

    var
    chr:array[0..299]of string;
    n,i,j,a,x,uu,code:integer;
    w:string;
    Begin
    a:=0;
    w:='0';
    readln(chr[0]);
    uu:=length(chr[0]);
    for i:=1 to uu do
    chr[i]:=copy(chr[0],i,1);

    readln(n);

    repeat

    for i:=1 to uu do
    if chr[i]>w then begin w:=chr[i]; x:=i end;
    delete(chr[x],1,1);
    a:=a+1;
    w:='0';

    until a=n;
    for i:=1 to uu do
    write(chr[i]);
    End.

    这题我在电脑上验证了好几个数据都是对的,咋WA了呢

  • 0
    @ 2012-10-09 21:54:57

    暴力的比较超了两个点

    var

    s,ss:string;

    n,i:integer;

    function del(s:string;i,j:integer):string;

    begin

    delete(s,i,j);

    del:=s;

    end;

    begin

    readln(s);

    readln(n);

    while n>0 do begin

    ss:=del(s,1,1);

    for i:=2 to length(s) do

    if ss>del(s,i,1) then ss:=del(s,i,1);

    s:=ss;

    dec(n);

    end;

    while s[1]='0' do delete(s,1,1);

    writeln(s);

    end.

  • 0
    @ 2009-11-04 18:12:51

    汗,我做过的第一道贪心题。

    意思是:有一个数字,如178543,删掉n个数字,使剩下的数最小。

  • 0
    @ 2009-11-03 12:58:37

    ├ 测试数据 01:答案正确... 0ms

    ├ 测试数据 02:答案正确... 0ms

    ├ 测试数据 03:答案正确... 0ms

    ├ 测试数据 04:答案正确... 0ms

    ├ 测试数据 05:答案正确... 0ms

    ├ 测试数据 06:答案正确... 0ms

    ├ 测试数据 07:答案正确... 0ms

    ├ 测试数据 08:答案正确... 0ms

    ├ 测试数据 09:答案正确... 0ms

    ├ 测试数据 10:答案正确... 0ms

    1006个。。。

  • 0
    @ 2009-11-02 22:28:05

    1005个,险些1000

    可惜了

    • -|||
  • 0
    @ 2009-11-02 16:50:51

    program sswt;

    var

    n:string;

    s,i,j:integer;

    begin

    readln(n);

    readln(s);

    for i:=1 to s do

    begin

    j:=1;

    while (length(n)>j)and(n[j]1)and(n[1]='0') do delete(n,1,1);

    writeln(n);

    end.

  • 0
    @ 2009-11-01 16:39:08

    program t1414(input,output);

    var str1:string;

    i,xx,n:longint;

    begin

    readln(str1);

    readln(n);

    for xx:=1 to n do

    begin

    i:=1;

    while (str1[i]

  • 0
    @ 2009-11-01 11:53:43

    偶竟然看不懂

  • 0
    @ 2009-10-19 16:21:19

    ...

    英语题+水题

    注意。。

    题目多处表述不清。。

    1:可以删1-9。(还可以删0);

    2:可以有前导的0,但是在输出时不输出。。但只有0时就输出0。

    例1:

    10023

    3

    例2:

    10023

    2

    3

    MY题解:

    http://254117343.blog.163.com/

  • 0
    @ 2009-10-09 15:12:10

    鄙人英语巨烂

    根本看不懂

    orz出题人

    把我整得这么惨 这么水的题目

    惟一看懂的就是 number in【1..9】结果还有0 够黑

    害的我还以为是所求的数最小 弄了个dp也能得20分 orz数据真好!!!!!

    以后出题给个中文翻译 叫人怎么做啊

  • 0
    @ 2009-10-07 00:36:27

    原来ac和10分之间,只差一个等号。。。

  • 0
    @ 2009-10-04 12:04:23

    脑子短路了。。这么简单的题目都要交两遍

    居然把 i 和 j弄混了

  • 0
    @ 2009-09-23 12:49:46

    感谢题解!

    var i,j,n,m,k,l,o,p:longint;

    q,w,e:string;

    begin

    readln(q);

    readln(n);

    while n>0 do

    begin

    i:=1;

    while (q[i]

  • 0
    @ 2009-08-29 09:25:17

    无输出等于超时?无语……

信息

ID
1414
难度
6
分类
贪心 点击显示
标签
递交数
2277
已通过
640
通过率
28%
被复制
3
上传者