题解

211 条题解

  • 0
    @ 2009-10-06 10:34:37

    原题好像不用输出STEP=

    直接输出步数的

    结果4个WA

  • 0
    @ 2009-10-06 00:40:34

    竟然忘记10+进制的输入可能有字母,被水题虐了

  • 0
    @ 2009-10-03 10:24:11

  • 0
    @ 2009-09-26 15:32:52

    哎,如此水题竟未一次AC

    一切只因“Imopssible” 后面还有一个“!”

  • 0
    @ 2009-09-24 13:07:39

    Var

    a,b:array[1..5000]of integer;

    i,n,x,m,f,len1,w:longint;

    s1:string;

    Begin

    m:=0;

    readln(x);

    read(s1);

    len1:=length(s1);

    for i:=1 to len1 do

    if (s1[i]'0')and(s1[i]'1')and(s1[i]'2')and(s1[i]'3')and(s1[i]'4')and(s1[i]'5')and(s1[i]'6')and(s1[i]'7')and(s1[i]'8')and(s1[i]'9')

    then if s1[i]='A'

    then a[len1-i+1]:=10

    else if s1[i]='B'

    then a[len1-i+1]:=11

    else if s1[i]='C'

    then a[len1-i+1]:=12

    else if s1[i]='D'

    then a[len1-i+1]:=13

    else if s1[i]='E'

    then a[len1-i+1]:=14

    else a[len1-i+1]:=15;

    if len1=1 then begin write('STEP=0');

    halt; end;

    for i:=1 to len1 do

    begin

    if (s1[i]'0')and(s1[i]'1')and(s1[i]'2')and(s1[i]'3')and(s1[i]'4')and(s1[i]'5')and(s1[i]'6')and(s1[i]'7')and(s1[i]'8')and(s1[i]'9')

    then continue;

    val(s1[i],a[len1-i+1])

    end;

    for i:=1 to 30 do

    begin

    f:=0;

    for n:=1 to (len1 div 2) do

    if a[n]=a[len1-n+1] then f:=f+1;

    if f=(len1 div 2) then begin write('STEP=',m);

    exit

    end;

    m:=m+1;

    for n:=1 to len1 do

    b[n]:=a[len1-n+1];

    for n:=1 to len1 do begin

    a[n]:=a[n]+b[n];

    if a[n]>=x then begin

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

    a[n]:=a[n]-x;

    end;

    end;

    if a[len1+1]=1 then len1:=len1+1

    end;

    write('Impossible!')

    End.

  • 0
    @ 2009-09-20 15:32:08

    崩溃啊,很白痴地化成10进制去计算,居然很不幸地过了一个点,还以为是细节错……

  • 0
    @ 2009-09-17 21:16:56

    if js=31 then begin writeln('Impossible!'); halt; end

    该死的感叹号。。。

  • 0
    @ 2009-09-16 18:11:41

    快一年了……

    我的做法竟然与去年的做法几乎一样(楼下dsdgzy是我去年的号)

    一次AC

    编译通过...

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

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

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

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

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

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

    var

    n,i,j,k:longint;

    a,b:array[0..100]of longint;

    m:string;

    procedure make;

    var i:longint;

    begin

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

    for i:=1 to a[0]do

    b[i]:=a[a[0]-i+1];

    for i:=1 to a[0] do

    b[i]:=a[i]+b[i];

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

    for i:=1 to a[0] do

    begin

    a[i]:=b[i] mod n;

    b:=b+b[i] div n;

    end;

    while a[a[0]]=0 do dec(a[0]);

    end;

    function pan:boolean;

    var i:longint;

    begin

    for i:=1 to a[0]do

    if a[i]a[a[0]+1-i]then exit(false);

    exit(true);

    end;

    begin

    readln(n);

    readln(m);

    a[0]:=length(m);

    for i:=1 to a[0]do

    begin

    if (m[i]>='0')and(m[i]30);

    if j

  • 0
    @ 2009-09-16 13:29:54

    谁有第二个点的数据

  • 0
    @ 2009-09-09 13:11:59

    因为某个下标搞错了。。。

    WA了n次- -!

    program hws;

    var

    i,j,k,m,n:longint;

    s:string;

    function ishw(ss:string):boolean;

    var

    ii:longint;

    ss1:string;

    begin

    ss1:='';

    for ii:=1 to length(ss) do ss1:=ss[ii]+ss1;

    if ss=ss1 then exit(true) else exit(false);

    end;

    procedure makes(ss:string);

    var

    s2,kk:string;

    ii,jj,lens,code:longint;

    p1,p2:array[1..1000]of integer;

    begin

    s2:='';

    lens:=length(ss);

    p1[lens+1]:=0;

    p2[lens+1]:=0;

    for ii:=1 to length(ss) do s2:=ss[ii]+s2;

    for ii:=1 to length(ss) do

    begin

    case ss[ii] of

    '0'..'9':val(ss[ii],p1[ii],code);

    'A':p1[ii]:=10;

    'B':p1[ii]:=11;

    'C':p1[ii]:=12;

    'D':p1[ii]:=13;

    'E':p1[ii]:=14;

    'F':p1[ii]:=15;

    end;

    end;

    for ii:=1 to length(s2) do

    begin

    case s2[ii] of

    '0'..'9':val(s2[ii],p2[ii],code);

    'A':p2[ii]:=10;

    'B':p2[ii]:=11;

    'C':p2[ii]:=12;

    'D':p2[ii]:=13;

    'E':p2[ii]:=14;

    'F':p2[ii]:=15;

    end;

    end;

    for ii:=1 to length(ss) do

    begin

    p1[ii]:=p1[ii]+p2[ii];

    p1[ii+1]:=p1[ii+1]+(p1[ii] div n);

    p1[ii]:=p1[ii] mod n;

    end;

    if p1[lens+1]0 then inc(lens);

    s:='';

    for ii:=lens downto 1 do

    case p1[ii] of

    0..9:begin str(p1[ii],kk); s:=s+kk; end;

    10..15:s:=s+chr(p1[ii]+55);

    end;

    end;

    begin

    readln(n);

    readln(s);

    if ishw(s) then begin writeln(‘STEP=’,0); exit; end;

    for i:=1 to 30 do

    begin

    makes(s);

    if ishw(s) then begin writeln('STEP=',i); exit; end;

    end;

    writeln('Impossible!');

    end.

  • 0
    @ 2009-09-06 12:28:51

    const

    g:packed array['A'..'Z']of integer=(10,11,12,13,14,15,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36);

    h:packed array[10..35]of char=('A','B','C','D','E','F','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z');

    var

    n,i,j,t,k,p:longint;

    st,st1,st2:string;

    procedure check(st:string);

    var

    i:integer;

    flag:boolean;

    begin

    flag:=true;

    for i:=1 to (length(st) div 2) do

    if st[i]st[length(st)-i+1] then begin flag:=false;break;end;

    if flag then begin write('STEP=',t);halt;end;

    end;

    function jia(st:string):string;

    var

    st1,st2:string;

    i,j,k,p,t,x1,x2:longint;

    begin

    st2:='';p:=0;st1:='';

    for i:=1 to length(st) do st2:=st[i]+st2;

    for i:=length(st) downto 1 do

    begin

    if ord(st[i])>=65 then x1:=g[st[i]]

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

    if ord(st2[i])>=65 then x2:=g[st2[i]]

    else x2:=ord(st2[i])-48;

    x1:=x1+x2+p;p:=x1 div n;x1:=x1 mod n;

    if x1>=10 then st1:=h[x1]+st1

    else st1:=chr(x1+48)+st1;

    end;

    if p0 then if p>=10 then st1:=h[p]+st1

    else st1:=chr(p+48)+st1;

    jia:=st1;

    end;

    begin

    readln(n);read(st);t:=0;

    while t

  • 0
    @ 2009-08-31 08:45:09

    要命的感叹号~

  • 0
    @ 2009-08-28 14:27:37

    第二个测试数据我竟然猜对了

    其它数据我原本就对

    AC!!!

  • 0
    @ 2009-08-28 10:13:54

    var

    c,a:array[1..1000]of longint;

    len,step,n,m,k,i,j,l:longint;

    s:string;

    function check :boolean;

    var i:longint;

    begin

    for i:=1 to len div 2 do

    if c[i]c[len-i+1] then

    exit(false);

    exit(true);

    end;

    begin

    readln(n);

    readln(s);

    step:=0; len:=length(s);

    for i:=1 to len do

    begin

    if (s[i]>='0')and(s[i]='A')and(s[i]30 then begin writeln('Impossible!');halt; end;

    if check then begin writeln('STEP=',step);halt; end;

    a:=c;

    fillchar(c,sizeof(c),0);

    until false;

    end.

  • 0
    @ 2009-08-24 17:14:20

    无语……这可是水题啊……我居然……

    注意叹号!要写'!',不要写'!'我就囧在这了

    ……

    BS出题人,为啥打个!而不是!……!!!

    编译通过...

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

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

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

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

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

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

  • 0
    @ 2009-08-19 15:41:30

    编译通过...

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

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

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

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

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

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

    呵呵,第三次了

  • 0
    @ 2009-08-18 16:39:22

    var

    l,n,i,s,k,j:longint;

    m:string;

    a,b:array[0..1000] of integer;

    begin

    readln(n);

    readln(m);

    l:=length(m);

    for i:=l downto 1 do

    case m[i] of

    'A'..'F':a[l-i+1]:=ord(m[i])-55;

    '0'..'9':a[l-i+1]:=ord(m[i])-48;

    end;

    repeat

    b:=a;

    for i:=1 to l+1 do

    begin

    k:=b[i]+b[l-i+1]+k;

    a[i]:=k mod n;

    k:=k div n;

    end;

    if a[l+1]0 then

    begin

    j:=l+1;

    l:=l+1;

    end

    else j:=l;

    i:=1;

    while (i=j then begin

    writeln('STEP=',s+1);

    halt;

    end;

    s:=s+1;

    until s=30;

    writeln('Impossible!');

    end.

  • 0
    @ 2009-08-15 18:15:41

    编译通过...

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

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

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

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

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

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

    program vijos1304;

    var a,b:array[1..10000]of integer;

    step,n,i,j,l:integer;

    m:string;

    procedure init;

    var i:integer;

    begin

    l:=length(m);

    for i:=1 to l do

    case m[l-i+1] of

    'A'..'F':a[i]:=ord(m[l-i+1])-55;

    '1'..'9':a[i]:=ord(m[l-i+1])-48;

    end;

    end;

    function pd:boolean;

    var i:integer;

    begin

    pd:=true;

    for i:=1 to l do

    if a[i]a[l-i+1] then exit(false);

    end;

    procedure p(t:integer);

    var i,j:integer;

    begin

    if t>30 then write('Impossible! ')

    else begin

    for i:=1 to l do

    b[i]:=a[l-i+1];

    for i:=1 to l do

    begin

    a[i]:=a[i]+b[i];

    a:=(a[i] div n)+a;

    a[i]:=a[i] mod n

    end;

    while a[l+1]0 do inc(l);

    if pd then write('STEP=',t)

    else p(t+1);

    end;

    end;

    begin

    readln(n);

    readln(m);

    init;

    p(1);

    end.

  • 0
    @ 2009-08-15 10:35:05

    此题建议全在 10进制环境下运算

    这样可以简化运算

  • 0
    @ 2009-08-08 09:48:21

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

    高精度加法+简单的字符串处理=AC

信息

ID
1304
难度
5
分类
模拟 点击显示
标签
递交数
8067
已通过
2523
通过率
31%
被复制
28
上传者