题解

135 条题解

  • 0
    @ 2009-07-29 11:46:47

    朴素?估计超时……

    打表?才是王道!

    {—————————————————}

    编译通过...

    ├ 测试数据 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-25 08:11:59

    var

    a1,b,i,j,x,y,ans:longint;

    begin

    readln(a1,b);

    for i:=a1 to b do

    begin

    x:=0;y:=0;

    for j:=1 to trunc(sqrt(i)) do

    if i mod j=0 then begin inc(x,j);

    if j>=2 then inc(x,i div j); end;

    if x>i then begin

    for j:=1 to trunc(sqrt(x)) do

    if x mod j=0

    then begin inc(y,j);

    if j>=2 then inc(y,x div j);

    end;

    if y=i

    then inc(ans);

    end;

    end;

    write(ans);

    end.

    绝对正确!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

  • 0
    @ 2009-07-23 11:39:42

    晕,裸搜。。

  • 0
    @ 2009-07-21 10:17:20

    题解(附程序):

  • 0
    @ 2009-07-11 16:50:59

    类似筛法做

    时间复杂度O(n/1+n/2+..+n/n)~=O(nlogn)

  • 0
    @ 2009-06-20 22:27:54

    不好意思,恕我直言,花时间打表交表的家伙是``EGGHEAD!!

    原始的穷举程序:

    var

    a1,b,i,j,x,y,ans:longint;

    begin

    readln(a1,b);

    for i:=a1 to b do

    begin

    x:=0;y:=0;for j:=1 to trunc(sqrt(i)) doif i mod j=0then begin inc(x,j); if j>=2 then inc(x,i div j); end;if x>ithen beginfor j:=1 to trunc(sqrt(x)) doif x mod j=0then begin inc(y,j); if j>=2 then inc(y,x div j); end ;if y=ithen inc(ans);end;

    end;

    write(ans);

    end.

    p.s.空行有点多哈~~

    结果:

    编译通过...

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

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

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

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

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

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

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

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

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

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

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

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

    交表的惨了吧~~~

    (puppy就是好···)

  • 0
    @ 2009-05-31 11:06:15

    编译通过...

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

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

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

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

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

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

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

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

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

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

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

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

    日死了,99900000 100000000这个数据自己机器上运行要4秒,一交,AC。

  • 0
    @ 2009-05-14 20:03:24

    var

    a1,a2,p,i,o,j,s:longint;

    begin

    readln(a1,a2); s:=0;

    for i:=a1 to a2 do begin

    p:=1; o:=1;

    for j:=2 to trunc(sqrt(i)) do

    if i mod j=0 then p:=p+j+(i div j);

    if p>i then for j:=2 to trunc(sqrt(p)) do

    if p mod j=0 then o:=o+j+(p div j);

    if (o=i) then inc(s);

    end;

    writeln(s);

    end.

    优化就行了

  • 0
    @ 2009-05-10 17:03:54

    不用打表,我一次AC的,才多少行啊?几十而已!

  • 0
    @ 2009-05-07 12:21:40

    谢谢你的表├ 测试数据 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-03-29 16:43:50

    var a,b,d,i,j:longint;

    function ss(a3:longint):longint;

    var a2,a4:longint;

    begin

    a4:=1;

    for a2:=2 to trunc(sqrt(a3)) do

    if (a3 mod a2)=0 then a4:=a4+a2+(a3 div a2);

    exit(a4);

    end;

    begin

    readln(a,b);

    j:=0;

    for i:=a to b do

    begin

    d:=ss(i);

    if (d>i) and (ss(d)=i) then inc(j);

    end;

    write(j);

    end.

  • 0
    @ 2009-03-16 09:17:08

    I use C++: 50 5points TLE

    I use C: 10 9points TLE

    I use PASCAL: AC

    why?

  • 0
    @ 2009-02-07 01:11:29

    数据实则没有那么BT吧,我试一下竟然过了……

    INPUT:99900000 100000000

    谁试试能过这个数据的(非表)

    复杂度全在计算亲和数上了

  • 0
    @ 2009-02-05 16:07:58

    打表是王道

  • 0
    @ 2009-02-02 15:12:20

    吓死我了,以为穷举能tle呢,没想到AC了。。。

    害的我让电脑跑了那么长时间弄出个表(笔记本的风扇呼呼转啊),最后交的还是穷举的程序。。。。

  • 0
    @ 2009-01-24 15:28:20

    1次ac,简单

    编译通过...

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

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

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

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

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

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

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

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

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

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

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

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

    程序很短;

    主要思路:

    首先在函数中有一个累加器,初值为1

    因为所有的数都有一个约数1,并且在本题中约数计算不包括自己;

    根据判断素数的思想我们知道如果一个数是合数,那么在它的平方根以内必有至少一个约数;

    根据这个,我们判断一个数只需从2开始判断,判断到sqrt(n)以下,也即是

    for i := 2 to trunc(sqrt(n)) do ...

    注意是trunc,不是四舍五入,虽然换成四舍五入时间损失也非常小,但这是习惯问题,如果你编的一个大程序调用这个函数上万遍,这样就会浪费上万的时间;

    而且如果n=j*(j+1),四舍五入可能会导致出现错误(合数重复计算,即在合数中重复加入了i和i+1),虽然我在1*2至100*101之间都没有发现这类错误(因为之间的数的平方根都属于被“四舍”而不是“五入”,即在效果上与trunc相同),但我认为理论上仍然存在错误的可能;

    然后找到它的约数之后,在累加器中加上i以及与i配对的约数(n div i)(配对就是两个约数积为n,比如6的约数中的2和3)

    参考程序:

    var a,b,d,i,j:longint;

    function ss(a3:longint):longint;

    var a2,a4:longint;

    begin

    a4 := 1;

    for a2 := 2 to trunc(sqrt(a3)) do if (a3 mod a2)=0 then a4 := a4+a2+(a3 div a2);

    exit(a4);

    end;

    begin

    readln(a,b);

    j := 0;

    for i := a to b do begin

    d := ss(i);

    if (d>i)and(ss(d) = i) then inc(j);

    end;

    write(j);

    end.

  • 0
    @ 2009-01-13 18:21:42

    1次AC,感觉真好.

    给做这道题的朋友的一个提示:直接做可以过!!!!不会超时!!!!

    时间:

    编译通过...

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

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

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

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

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

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

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

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

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

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

    参考程序:

    var s,i:longint;

    a1,a2:int64;

    bo:array[0..10000000]of boolean;

    procedure expand2(a:longint);

    var now,j:longint;

    begin

    now:=0;

    for j:=1 to trunc(sqrt(a)) do

    begin

    if a mod j=0 then

    begin

    now:=now+j+a div j;

    if j=1 then now:=now-a;

    end;

    end;

    if now=i then inc(s);

    end;

    procedure expand(a:longint);

    var now,i:longint;

    begin

    now:=0;

    for i:=1 to trunc(sqrt(a)) do

    begin

    if a mod i=0 then

    begin

    now:=now+i+a div i;

    if i=1 then now:=now-a;

    end;

    end;

    if (now>a)and((not bo[now])or(now>a2)) then expand2(now);

    end;

    procedure make;

    var i,j:longint;

    begin

    fillchar(bo,sizeof(bo),true);

    bo[1]:=false;

    for i:=1 to trunc(sqrt(a2)) do

    begin

    if bo[i] then

    begin

    for j:=2 to a2 div i do

    if (i*j)

  • 0
    @ 2009-01-07 22:27:03

    var

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

    procedure run(x:longint);

    var

    i,j,w:longint;

    begin

    j:=0;

    for i:=1 to trunc(sqrt(x)) do

    if x mod i=0

       then begin

         if i1

         then j:=j+i+x div i

         else j:=j+i;

         end;

    if j=v

    then inc(k);

    end;

    procedure li(x:longint);

    var

    i,k,w:longint;

    begin

    k:=0;

    for i:=1 to trunc(sqrt(x)) do

    begin

    if x mod i=0

       then begin

         if i1

         then k:=k+i+x div i

         else k:=k+i;

        end;

        end;

    if k>x

    then run(k);

    end;

    begin

    read(n,m);

    for v:=m downto n do

    if (not(odd(v)))or(odd(v)and(v mod 10=5))

    then

    li(v);

    write(k);

    end.

  • 0
    @ 2008-12-13 17:11:34

    交表力量无穷大!!!

  • 0
    @ 2008-12-06 17:55:48

    谢谢表

    const h:array[1..100]of longint=(220,1184,2620,5020,6232,10744,12285,17296,63020,66928,67095,

    69615,79750,100485,122265,122368,141664,142310,171856,176272,

    185368,196724,280540,308620,319550,356408,437456,469028,503056,

    522405,600392,609928,624184,635624,643336,667964,726104,802725,

    879712,898216,947835,998104,1077890,1077890,1154450,1280565,

    1392368,1511930,1798875,2082464,4238984,5459176,6329416,7677248,

    9363584,10254970,13921528,16137628,50997596,52695376,56055872,

    56512610,56924192,58580540,59497888,63560025,63717615,66595130,

    66854710,67729064,67738268,68891992,71015260,71241830,72958556,

    73032872,74055952,74386305,74769345,75171808,75226888,78088504,

    78447010,79324875,80422335,82633005,83135650,84521745,84591405,

    86158220,87998470,88144630,89477984,90437150,91996816,93837808,

    95629904,95791430,96304845,97041735);

    var

    x,y,i,n:longint;

    begin

    n:=0;

    read(x,y);

    for i:=1 to 100 do if (h[i]>=x) and (h[i]

信息

ID
1216
难度
5
分类
模拟 点击显示
标签
(无)
递交数
2685
已通过
891
通过率
33%
被复制
5
上传者