题解

129 条题解

  • 0
    @ 2009-11-08 08:55:41

    求求上帝把这道题删掉,这种比一般恶心更恶心的题目,迫害我们oier的大脑!!!!

  • 0
    @ 2009-11-07 17:33:11

    对于这种KMP都过不去的题...



    Orz

  • 0
    @ 2009-11-04 19:41:54

    编译通过...

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    ---|---|---|---|---|---|---|---|-

    Accepted 有效得分:100 有效耗时:0ms

    膜拜huyue神牛的数据‘0’直接让我由92分变AC!

    注意全‘0’的情况!

  • 0
    @ 2009-11-01 13:34:14

    感动啊~ 终于A了~

    ural上有大量数据~

  • 0
    @ 2009-10-30 19:25:25

    const

    maxl = 2000;

    type

    bitnode = array[0..maxl+1]of longint;

    var

    len, c,n: longint;

    t : array[1..maxl]of shortint;

    best, a, b : bitnode;

    procedure init;

    var

    st : string[200];

    i : longint;

    begin

    readln(st);

    len := length(st);

    for i := 1 to len do begin

    t[i] := ord(st[i])-48;

    end;

    end;

    procedure dec1(var a : bitnode);

    var i : longint;

    begin

    i := 1;

    while a[i] = 0 do begin

    a[i] := 9; inc(i);

    end;

    dec(a[i]);

    if (a[0] > 1) and (a[a[0]] = 0) then dec(a[0]);

    end;

    procedure inc1(var a : bitnode);

    var i : longint;

    begin

    i := 1;

    inc(a[i]);

    while a[i] = 10 do begin

    a[i] := 0;

    inc(i);

    inc(a[i]);

    end;

    if a[a[0]+1] 0 then inc(a[0]);

    end;

    function match(i : longint) : boolean;

    var j : longint;

    begin

    if a[0] < i then begin

    if t[1] 8 then exit(false);

    for j := 1 to a[0] do begin

    if t a[j] then exit(false);

    end;

    exit(true);

    end else begin

    for j := 1 to i do

    if t a[j] then exit(false);

    exit(true);

    end;

    end;

    function can(i : longint) : boolean;

    var j : longint;

    begin

    while i < len do begin

    inc1(b);

    j := i+1;

    while (j b[0] then exit(true);

    if a[0] < b[0] then exit(false);

    for i := a[0] downto 1 do begin

    if a[i] > b[i] then exit(true);

    if a[i] < b[i] then exit(false);

    end;

    exit(false);

    end;

    procedure main;

    var l, i, j, tem : longint; flag : boolean;

    begin

    flag := true;

    for i := 1 to len do if t[i] 0 then begin flag := false; break; end;

    if flag then begin

    best[0] := len+1; best[best[0]] := 1; c := 1;

    print;

    end;

    for i := 1 to len do best[i] := t[len-i+1];

    best[0] := len;

    if t[1] = 0 then begin

    inc(best[0]);

    best[best[0]] := 1;

    end;

    for i := len-len shr 1-1 downto 0 do begin

    flag := true;

    for j := 1 to i do if t[j] t[len-i+j] then begin

    flag := false; break;

    end;

    if flag then begin

    a[0] := len-i;

    tem := 0;

    for j := 1 to a[0] do a[j] := t[a[0]-j+1];

    for j := 1 to a[0]-i do begin

    if (a[a[0]] 0) and ((i = 0) or (a[1] 9) or (t 9)) then if bigger(best, a) then begin best := a; c := tem; end;

    a[a[0]+1] := a[1];

    for l := 1 to a[0] do a[l] := a[l+1];

    a[a[0]+1] := 0;

    inc(tem);

    end;

    end;

    end;

    for l := 1 to best[0] do begin

    for i := l downto 1 do if (i < len) and (t 0) then begin

    fillchar(b, sizeof(b), 0);

    b[0] := l;

    for j := l downto 1 do begin

    if i+l-j+1 > len then break;

    b[j] := t;

    end;

    if (b[0] = 1) and (b[1] = 1) then continue;

    a := b; dec1(a);

    if match(i)

    and can(i+l) then begin

    if bigger(best, a) then begin

    c := a[0]-i;

    best := a;

    end;

    end;

    end;

    end;

    print;

    end;

    begin

    init;

    main;

    end.

  • 0
    @ 2009-10-24 14:58:21

    这题够损!

    编译通过...

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    ---|---|---|---|---|---|---|---|-

    Accepted 有效得分:100 有效耗时:0ms

    #include

    using namespace std;

    typedef int array[410];

    int n;

    int test1(array a,int p,int q)

    {

    int flag=0,f,i,j,k,p1,q1,pp,qq;

    array b,c;

    p1=p;q1=q;

    do

    {

    pp=p;qq=q;

    for (i=p;i=q+1;i--)

    {

    b[i]=a;

    if (b>=10)

    {

    b-=10;

    b[i]++;

    }

    }

    if (flag) b[q+1]=1;

    for (i=q+1;in) break;

    if (a[i]!=b[i]) return 0;

    }

    p=qq+1;

    q=2*qq-pp+flag+1;

    }while (i

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

    暴力55分啊

    program p1005;

    var

    s,s1,a,a1:string;

    i,l,ll:int64;

    j:longint;

    t:boolean;

    begin

    readln(s);

    l:=length(s);

    a:='';

    ll:=1;

    i:=1;

    while t=false do

    begin

    str(i,s1);

    a1:=a+s1;

    for j:=1 to length(a1)-l+1 do

    if copy(a1,j,l)=s then

    begin

    writeln(j+ll-1);

    t:=true;

    break;

    end;

    if length(a1)>=l then

    ll:=ll+length(a1)-l+1;

    a:=copy(a1,length(a1)-l+2,l-1);

    i:=i+1

    end;

    end.

    程序简便么用啊

  • 0
    @ 2009-09-19 15:17:13

    const

    maxl = 2000;

    type

    bitnode = array[0..maxl+1]of longint;

    var

    len, c,n: longint;

    t : array[1..maxl]of shortint;

    best, a, b : bitnode;

    procedure init;

    var

    st : string[200];

    i : longint;

    begin

    readln(st);

    len := length(st);

    for i := 1 to len do begin

    t[i] := ord(st[i])-48;

    end;

    end;

    procedure dec1(var a : bitnode);

    var i : longint;

    begin

    i := 1;

    while a[i] = 0 do begin

    a[i] := 9; inc(i);

    end;

    dec(a[i]);

    if (a[0] > 1) and (a[a[0]] = 0) then dec(a[0]);

    end;

    procedure inc1(var a : bitnode);

    var i : longint;

    begin

    i := 1;

    inc(a[i]);

    while a[i] = 10 do begin

    a[i] := 0;

    inc(i);

    inc(a[i]);

    end;

    if a[a[0]+1] 0 then inc(a[0]);

    end;

    function match(i : longint) : boolean;

    var j : longint;

    begin

    if a[0] < i then begin

    if t[1] 8 then exit(false);

    for j := 1 to a[0] do begin

    if t a[j] then exit(false);

    end;

    exit(true);

    end else begin

    for j := 1 to i do

    if t a[j] then exit(false);

    exit(true);

    end;

    end;

    function can(i : longint) : boolean;

    var j : longint;

    begin

    while i < len do begin

    inc1(b);

    j := i+1;

    while (j b[0] then exit(true);

    if a[0] < b[0] then exit(false);

    for i := a[0] downto 1 do begin

    if a[i] > b[i] then exit(true);

    if a[i] < b[i] then exit(false);

    end;

    exit(false);

    end;

    procedure main;

    var l, i, j, tem : longint; flag : boolean;

    begin

    flag := true;

    for i := 1 to len do if t[i] 0 then begin flag := false; break; end;

    if flag then begin

    best[0] := len+1; best[best[0]] := 1; c := 1;

    print;

    end;

    for i := 1 to len do best[i] := t[len-i+1];

    best[0] := len;

    if t[1] = 0 then begin

    inc(best[0]);

    best[best[0]] := 1;

    end;

    for i := len-len shr 1-1 downto 0 do begin

    flag := true;

    for j := 1 to i do if t[j] t[len-i+j] then begin

    flag := false; break;

    end;

    if flag then begin

    a[0] := len-i;

    tem := 0;

    for j := 1 to a[0] do a[j] := t[a[0]-j+1];

    for j := 1 to a[0]-i do begin

    if (a[a[0]] 0) and ((i = 0) or (a[1] 9) or (t 9)) then if bigger(best, a) then begin best := a; c := tem; end;

    a[a[0]+1] := a[1];

    for l := 1 to a[0] do a[l] := a[l+1];

    a[a[0]+1] := 0;

    inc(tem);

    end;

    end;

    end;

    for l := 1 to best[0] do begin

    for i := l downto 1 do if (i < len) and (t 0) then begin

    fillchar(b, sizeof(b), 0);

    b[0] := l;

    for j := l downto 1 do begin

    if i+l-j+1 > len then break;

    b[j] := t;

    end;

    if (b[0] = 1) and (b[1] = 1) then continue;

    a := b; dec1(a);

    if match(i)

    and can(i+l) then begin

    if bigger(best, a) then begin

    c := a[0]-i;

    best := a;

    end;

    end;

    end;

    end;

    print;

    end;

    begin

    init;

    main;

    end.

  • 0
    @ 2009-09-17 07:41:14

    恶心的题............还好过了,不建议在这道题上面浪费时间。。

  • 0
    @ 2009-09-16 17:42:39

    暴力破解,55!!!!!我还是等几年在来做这题吧!

    program superstring;

    var s:ansistring;

    n,si:string;

    ln,i,j,z,v,l:longint;

    begin

    readln(n);

    ln:=length(n);

    i:=0;

    while v100 do

    begin

    inc(i);

    str(i,si);

    s:=s+si;

    l:=length(s);

    if l>=ln then

    begin

    for j:=1 to l-ln+1 do

    begin

    z:=1;

    while n[z]=s[j+z-1] do

    begin

    inc(z);

    if z=ln+1 then begin write(j); exit; end;

    end;

    end;

    end;

    end;

    end.

    编译通过...

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

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

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

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

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

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

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

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

    ├ 测试数据 09:运行超时...

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

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

    ├ 测试数据 12:答案正确... 572ms

    ├ 测试数据 13:运行超时...

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

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

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

    ├ 测试数据 17:运行超时...

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

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

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

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

    ├ 测试数据 22:运行超时...

    ├ 测试数据 23:运行超时...

    ├ 测试数据 24:运行超时...

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

    ├ 测试数据 26:运行超时...

    ├ 测试数据 27:运行超时...

    ├ 测试数据 28:运行超时...

    ├ 测试数据 29:运行超时...

    ├ 测试数据 30:运行超时...

    ├ 测试数据 31:运行超时...

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

    ├ 测试数据 33:运行超时...

    ├ 测试数据 34:运行超时...

    ├ 测试数据 35:运行超时...

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

    ├ 测试数据 37:运行超时...

    ├ 测试数据 38:运行超时...

    ├ 测试数据 39:运行超时...

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

  • 0
    @ 2009-09-13 13:33:08

    用KMP字符串匹配吧。

  • 0
    @ 2009-09-05 14:00:49

    无cheat82分

  • 0
    @ 2009-08-10 09:51:36

    他喵的 好令人无语的数据......

  • 0
    @ 2009-08-03 17:51:26

    如对本题有疑问可以参看我的题解:http://xujieqi.blog.hexun.com/35722312_d.html

  • 0
    @ 2009-07-30 22:05:55

    枚举第一个数字是x位的,出现了后y位,然后依次检查看剩下的是否合法,确定了(x,y)后再用数学方法计算答案

  • 0
    @ 2009-07-29 20:20:24

    const

    maxl = 2000;

    type

    bitnode = array[0..maxl+1]of longint;

    var

    len, c : longint;

    t : array[1..maxl]of shortint;

    best, a, b : bitnode;

    procedure init;

    var

    st : string[200];

    i : longint;

    begin

    readln(st);

    len := length(st);

    for i := 1 to len do begin

    t[i] := ord(st[i])-48;

    end;

    end;

    procedure dec1(var a : bitnode);

    var i : longint;

    begin

    i := 1;

    while a[i] = 0 do begin

    a[i] := 9; inc(i);

    end;

    dec(a[i]);

    if (a[0] > 1) and (a[a[0]] = 0) then dec(a[0]);

    end;

    procedure inc1(var a : bitnode);

    var i : longint;

    begin

    i := 1;

    inc(a[i]);

    while a[i] = 10 do begin

    a[i] := 0;

    inc(i);

    inc(a[i]);

    end;

    if a[a[0]+1] 0 then inc(a[0]);

    end;

    function match(i : longint) : boolean;

    var j : longint;

    begin

    if a[0] < i then begin

    if t[1] 8 then exit(false);

    for j := 1 to a[0] do begin

    if t a[j] then exit(false);

    end;

    exit(true);

    end else begin

    for j := 1 to i do

    if t a[j] then exit(false);

    exit(true);

    end;

    end;

    function can(i : longint) : boolean;

    var j : longint;

    begin

    while i < len do begin

    inc1(b);

    j := i+1;

    while (j b[0] then exit(true);

    if a[0] < b[0] then exit(false);

    for i := a[0] downto 1 do begin

    if a[i] > b[i] then exit(true);

    if a[i] < b[i] then exit(false);

    end;

    exit(false);

    end;

    procedure main;

    var l, i, j, tem : longint; flag : boolean;

    begin

    flag := true;

    for i := 1 to len do if t[i] 0 then begin flag := false; break; end;

    if flag then begin

    best[0] := len+1; best[best[0]] := 1; c := 1;

    print;

    end;

    for i := 1 to len do best[i] := t[len-i+1];

    best[0] := len;

    if t[1] = 0 then begin

    inc(best[0]);

    best[best[0]] := 1;

    end;

    for i := len-len shr 1-1 downto 0 do begin

    flag := true;

    for j := 1 to i do if t[j] t[len-i+j] then begin

    flag := false; break;

    end;

    if flag then begin

    a[0] := len-i;

    tem := 0;

    for j := 1 to a[0] do a[j] := t[a[0]-j+1];

    for j := 1 to a[0]-i do begin

    if (a[a[0]] 0) and ((i = 0) or (a[1] 9) or (t 9)) then if bigger(best, a) then begin best := a; c := tem; end;

    a[a[0]+1] := a[1];

    for l := 1 to a[0] do a[l] := a[l+1];

    a[a[0]+1] := 0;

    inc(tem);

    end;

    end;

    end;

    for l := 1 to best[0] do begin

    for i := l downto 1 do if (i < len) and (t 0) then begin

    fillchar(b, sizeof(b), 0);

    b[0] := l;

    for j := l downto 1 do begin

    if i+l-j+1 > len then break;

    b[j] := t;

    end;

    if (b[0] = 1) and (b[1] = 1) then continue;

    a := b; dec1(a);

    if match(i)

    and can(i+l) then begin

    if bigger(best, a) then begin

    c := a[0]-i;

    best := a;

    end;

    end;

    end;

    end;

    print;

    end;

    begin

    init;

    main;

    end.

    恶心的数据,

    幸好过了

  • 0
    @ 2009-07-21 08:17:24

    编译通过...

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    ├ 测试数据 29:答案正确... 338ms

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

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

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

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

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

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

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

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

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

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

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

    ---|---|---|---|---|---|---|---|-

    Accepted 有效得分:100 有效耗时:338ms

  • 0
    @ 2009-07-09 16:30:05

    过了的人不要骄傲

  • 0
    @ 2009-06-17 20:13:02

    一提交才发现——40个测试点……偶滴神啊……

信息

ID
1005
难度
8
分类
字符串 | KMP 点击显示
标签
(无)
递交数
6613
已通过
623
通过率
9%
被复制
29
上传者