题解

111 条题解

  • 0
    @ 2009-08-03 16:15:38

    性质1:完全平方数的末位数只能是0,1,4,5,6,9。

      性质2:奇数的平方的个位数字为奇数,十位数字为偶数。

  • 0
    @ 2009-08-03 15:34:17

    手算打表

    var

    zh:array[0..20] of longint;

    a1,a2,a3,a4,n,n1:longint;

    x:array[0..100] of longint;

    s1,s2:string;

    z:array[0..14] of string=('(0)','','(2)','(2+2(0))','(2(2))','(2(2)+2(0))','(2(2)+2)','(2(2)+2+2(0))','(2(2+2(0)))','(2(2+2(0))+2(0))','(2(2+2(0))+2)','(2(2+2(0))+2+2(0))','(2(2+2(0))+2(2))','(2(2+2(0))+2(2)+2(0))','(2(2+2(0))+2(2)+2)');

    begin

    readln(n);

    zh[0]:=1;

    for a1:=1 to 14 do zh[a1]:=zh[a1-1]*2;

    repeat

    for a1:=14 downto 0 do if n>=zh[a1] then break;

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

    x[x[0]]:=a1;

    n:=n-zh[a1];

    until n=0;

    s2:='';

    for a1:=1 to x[0] do

    begin

    s1:='2';

    s1:=s1+z[x[a1]];

    if a1x[0] then s1:=s1+'+';

    s2:=s2+s1;

    end;

    writeln(s2);

    end.

  • 0
    @ 2009-08-02 22:45:53

    Procedure pt(n : TIndex);

    var

    sg : Boolean;

    j,lp,np : TIndex;

    p : array[0..20] of Tindex;

    Begin

    if n=1 then exit

    else

    if n=0 then write('(0)')

    else

    begin

    write('(');

    np:=n;

    j:=-1;

    while np>0 do

    begin

    inc(j);

    p[j]:=np mod 2;

    np:=np div 2;

    end;

    sg:=false;

    lp:=j;

    For j:=lp downto 0 do

    begin

    if p[j]=1 then begin if sg then write('+'); write('2'); pt(j); sg:=true; end;

    end;

    write(')');

    end;

    End;

    递归递归哈哈哈

  • 0
    @ 2009-08-02 20:20:03

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

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

    表表准准 递归题 |v=1 --> '2(0)'

    思路:digui(v)--> |v=2 --> '2'

    |v>2 --> digui(2(max)+2(max2)+...+2(0))

  • 0
    @ 2009-08-01 20:30:31

    编译通过...

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

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

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

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

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

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

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

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

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

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

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

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

    秒杀!!!!!

    题解为:

    设读入的数为k.(如样例k=137);

    做一个表a数组:如a[2]=1;a[4]=2,即 a [ b ] =c为a的c次方等于b;

    然后递归:find(k);

    从k循环到1,找到小于等于k的最大的一个2的幂次方数(如4,8,16,32...),如样例137就找到128,即2的7次方.然后分别递归7(注意!!!是7而不是128!!!)和9(137-128=9),当k=1时直接输出2(0);

    还有一个提醒的是,当for i:=k downto 1 do时,找到一个就可以break了;

    造表的程序:

    fillchar(a,sizeof(a),0);

    a[2]:=1;

    for i:=3 to n do

    begin

    if (a[i div 2]>0)and(i mod 2=0) then a[i]:=a[i div 2]+1;

    end;

    递归的程序:

    procedure find(k:longint);

    var i:longint;

    begin

    if k=1 then begin write('2(0)');exit;end;

    for i:=k downto 1 do

    if a[i]>0 then

    begin

    if a[i]=1 then write('2') else

    begin

    write('2(');

    find(a[i]);

    write(')');

    end;

    if ki then

    begin

    write('+');

    find(k-i);

    end;

    break;

    end;

    end;

    希望对大家有帮助!

  • 0
    @ 2009-08-01 13:25:30

    我是怎么超时的呀?!

  • 0
    @ 2009-07-31 22:44:47

    编译通过...

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

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

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

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

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

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

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

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

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

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

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

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

    WS! 104line!(switch)

  • 0
    @ 2009-07-31 19:02:56

    请用鼠标拖动选择下列文字即可显示题解

    var n,i:integer; s:array [0..20000] of string;procedure run(n:integer); var i,j,k:integer; begin if s[n]'' then exit; j:=n; k:=16384; for i:=14 downto 0 do begin if j>=k then begin j:=j-k; if s[n]'' then s[n]:=s[n]+'+'; s[n]:=s[n]+'2'; if i1 then begin run(i); s[n]:=s[n]+'('+s[i]+')'; end; end; k:=k div 2; end; end;begin for i:=0 to 20000 do s[i]:=''; s[0]:='0'; readln(n); run(n); writeln(s[n]);end.

  • 0
    @ 2009-07-31 11:27:40

    program leo;

    const a:array[0..14]of longint=(1,2,4,8,16,32,64,128,256,512,1024,2048,4096,8192,16384);

    var n:longint;

    procedure try(x:longint);

    var i:longint;

    begin

    if x=a[0] then write('2(0)') else

    if x=a[1] then write('2') else

    if x=a[2] then write('2(2)') else

    if x=a[3] then write('2(2+2(0))') else

    if x=a[4] then write('2(2(2))') else

    if x=a[5] then write('2(2(2)+2(0))') else

    if x=a[6] then write('2(2(2)+2)') else

    if x=a[7] then write('2(2(2)+2+2(0))') else

    if x=a[8] then write('2(2(2+2(0)))') else

    if x=a[9] then write('2(2(2+2(0))+2(0))') else

    if x=a[10] then write('2(2(2+2(0))+2)') else

    if x=a[11] then write('2(2(2+2(0))+2+2(0))') else

    if x=a[12] then write('2(2(2+2(0))+2(2))') else

    if x=a[13] then write('2(2(2+2(0))+2(2)+2(0))') else

    if x=a[14] then write('2(2(2+2(0))+2(2)+2)') else

    begin

    for i:=14 downto 0 do

    if a[i]0 then begin write('+'); try(x-a[i]); end;

    end;

    end;

    begin

    readln(n);

    try(n);

    end.

  • 0
    @ 2009-07-31 08:52:07

    编译通过...

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

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

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

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

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

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

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

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

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

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

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

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

    水题啊 (^o^)/ 一次秒杀.

    ....

    晒下程序 给不想做的人提供免费的水题水解

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

    program p1597;

    var n:integer;

    procedure work(k:integer);

    var i,j,z:integer;

    a:array[0..16] of integer;

    begin

    z:=k; j:=0;

    repeat

    inc(j);

    a[j]:=z mod 2;

    z:=z div 2;

    until z=0;

    if j>2 then begin write('2('); work(j-1); write(')');end;

    for i:=j-1 downto 3 do

    if a[i]=1 then

    begin

    write('+2(');

    work(i-1);

    write(')')

    end;

    if a[2]=1 then begin if j>2 then write('+');write('2');end;

    if a[1]=1 then begin if j>1 then write('+');write('2(0)'); end;

    end;

    begin

    readln(n);

    work(n);

    end.

  • 0
    @ 2009-07-30 23:21:16

    编译通过...

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

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

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

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

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

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

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

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

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

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

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

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

    我爱水题……

    不过为了让这题有点价值,

    我没交表,

    而是编了几十行的递归!

  • 0
    @ 2009-07-30 19:21:25

    水题

    小小的搜索+预赋值

  • 0
    @ 2009-07-30 16:12:47

    暴力交表

    编译通过...

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

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

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

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

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

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

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

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

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

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

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

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

    a[0]:='0';

    a[1]:='2(0)';

    a[2]:='2';

    a[3]:='2+2(0)';

    a[4]:='2(2)';

    a[5]:='2(2)+2(0)';

    a[6]:='2(2)+2';

    a[7]:='2(2)+2+2(0)';

    a[8]:='2(2+2(0))';

    a[9]:='2(2+2(0))+2(0)';

    a[10]:='2(2+2(0))+2';

    a[11]:='2(2+2(0))+2+2(0)';

    a[12]:='2(2+2(0))+2(2)';

    a[13]:='2(2+2(0))+2(2)+2(0)';

    a[14]:='2(2+2(0))+2(2)+2';

  • 0
    @ 2009-07-30 15:57:03

    编译通过...

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

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

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

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

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

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

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

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

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

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

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

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

    var

    x:integer;

    procedure slove(n:integer);

    var t:array[0..14] of integer;

    i,flag:integer;

    begin

    for i:=0 to 14 do

    begin

    t[i]:=n mod 2;

    n:=n div 2;

    end;

    flag:=0;

    for i:=14 downto 0 do

    if t[i]0 then

    begin

    if flag=1 then write('+');

    if i=1 then write(2)

    else if i=0 then write('2(0)') else

    begin

    write('2(');

    slove(i);

    write(')');

    end;

    flag:=1;

    end;

    end;

    begin

    readln(x);

    slove(x);

    end.

    这应该算短的了,AC标程

  • 0
    @ 2009-07-30 14:02:59

    const sj:array [0..14] of string=('2(0)','2','2(2)','2(2+2(0))','2(2(2))','2(2(2)+2(0))','2(2(2)+2)','2(2(2)+2+2(0))','2(2(2+2(0)))','2(2(2+2(0))+2(0))','2(2(2+2(0))+2)','2(2(2+2(0))+2+2(0))','2(2(2+2(0))+2(2))','2(2(2+2(0))+2(2)+2(0))','2(2(2+2(0))+2(2)+2)');

    (数论问题嘛)预设好 + 一重循环,问题就解决了,谁让它最大才20000呢。

    但是竟然2次才AC,因为8..14的2(3)中3忘记改了,( ⊙ o ⊙ )啊!AC率啊,真是大头虾。

  • 0
    @ 2009-07-30 11:17:05

    我是第102个通过的(刚看到这道水题时只有99人通过……囧)。

  • 0
    @ 2009-07-30 10:59:06

    Flag    Accepted

    题号   P1597

    类型(?)   数论 / 数值

    通过   100人

    提交   196次

    通过率   51%

    难度   1

  • 0
    @ 2009-07-30 10:04:22

    = =递归里面变量问题导致这么一个水题竟然做了1小时........ORZ..........................................

  • 0
    @ 2009-07-30 09:35:32

    递归。

    编译通过...

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

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

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

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

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

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

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

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

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

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

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

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

  • 0
    @ 2009-07-29 22:30:34

    第2(2(2)+2)+2(2+2(0))+2(0)个AC~~

    编译通过...

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

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

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

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

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

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

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

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

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

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

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

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

    至于程序就不便于让你们看了~

    递归求解,把已求出的表示数保存起来,方便调用~~

信息

ID
1597
难度
3
分类
模拟 点击显示
标签
递交数
2824
已通过
1420
通过率
50%
被复制
10
上传者