题解

49 条题解

  • 0
    @ 2009-07-03 10:47:43

    神牛啊 。。。

    题目。。。

    这都可以做出来

  • 0
    @ 2009-07-01 19:44:01

    楼下的牛们。。。额。。。题目在哪里。。。上帝啊~~~

  • 0
    @ 2009-06-23 21:20:28

    神题啊!!!楼下的全是大牛!!!

    没看到题目,会穿试的大牛!

  • 0
    @ 2009-06-14 13:04:58

    我倒……神题啊……

  • 0
    @ 2009-06-06 13:51:14

    额..题目呢?!这里没有看到题目啊.你们怎么做出来的?

  • 0
    @ 2009-05-30 10:54:35

    交了两次

    第一次编译失败,因为uses math;

    我用的fpc2.2.4,没有自动调用math,如果是fpc for noi就不会这样了

    第二次ac

    本题的数据没有错误

    用的逐位逼近,思想类似于双精度除法

    不知何故,没有出现诸位大牛所说的ans=0的问题

    另外,回ether大牛

    其实没有必要枚举到length(s)

    可以证明

    lim 3√n*n*n+n*n+3*n =n

    i→∞

    事实上

    下取整(3√n*n*n+n*n+3*n)=ans

    故len=length(n:string) div 3+1

    程序如下:

    编译通过...

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

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

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

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

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

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

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

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

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

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

    program vijos_1375; { 大整数 }

    const

    maxn=250;

    type

    baseType=longint;

    highInt=record

    da:array[1..maxn] of baseType;

    len:integer;

    end;

    var

    a,b,three:highInt;

    f:array[1..9] of integer;

    procedure empty(var a:highInt);

    begin

    with a do

    begin

    len:=1;

    fillchar(da,sizeof(da),0);

    end;

    end;

    procedure copy(const a:highInt;var b:highInt);

    var

    i:integer;

    begin

    empty(b);

    b.len:=a.len;

    for i:=1 to b.len do

    b.da[i]:=a.da[i];

    end;

    function max(a,b:integer):integer;

    begin if a>b then exit(a); exit(b); end;

    function compare(const a,b:highInt):integer;

    var

    l:integer;

    begin

    if a.len>b.len then exit(1);

    if a.len0) and (a.da[l]=b.da[l]) do dec(l);

    if l=0

    then exit(0)

    else

    if a.da[l]>b.da[l]

    then exit(1)

    else exit(-1);

    end;

    procedure highInc(const a,b:highInt;var c:highInt);

    var

    i,l:integer;

    begin

    empty(c);

    l:=max(a.len,b.len);

    for i:=1 to l do

    begin

    inc(c.da[i],a.da[i]+b.da[i]);

    if c.da[i]>=10 then

    begin

    inc(c.da);

    dec(c.da[i],10);

    end;

    end;

    if c.da[l]>0 then inc(l);

    c.len:=l;

    end;

    procedure highMul(const a,b:highInt;var c:highInt);

    var

    i,j,l:integer;

    begin

    empty(c);

    for i:=1 to a.len do

    for j:=1 to b.len do

    begin

    inc(c.da,a.da[i]*b.da[j]);

    if c.da>=10 then

    begin

    inc(c.da,c.da div 10);

    c.da:=c.da mod 10;

    end

    end;

    l:=a.len+b.len+1;

    while (l>0) and (c.da[l]=0) do dec(l);

    c.len:=l;

    end;

    procedure init;

    var

    s:string;

    r:extended;

    i:integer;

    begin

    readln(s);

    empty(a);

    empty(b);

    empty(three);

    three.da[1]:=3;

    r:=0;

    with a do

    begin

    len:=length(s);

    for i:=1 to len do

    da[len-i+1]:=ord(s[i])-48;

    end;

    b.len:=(a.len div 3)+1;

    end;

    function func(const a:highInt):highInt;

    var

    b,c,d:highInt;

    begin

    highMul(a,a,b);

    highInc(a,b,c);

    highInc(c,three,b);

    highMul(b,a,func);

    end;

    procedure main;

    var

    i:integer;

    begin

    with b do

    begin

    for i:=len downto 1 do

    begin

    repeat

    inc(da[i]);

    if da[i]>9 then break;

    until compare(func(b),a)=1;

    dec(da[i]);

    end;

    while (len>1) and (da[len]=0) do dec(len);

    end;

    end;

    procedure print(const a:highInt);

    var

    i:integer;

    begin

    with a do

    for i:=len downto 1 do

    write(da[i]);

    writeln;

    end;

    begin

    init;

    main;

    print(b);

    end.

  • 0
    @ 2009-05-24 13:36:17

    又见鬼题。。。

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

    第1个点要注意!我被阴了两次,应该输出0的。

  • 0
    @ 2009-02-03 08:53:23

    高精求值的基本方法:

    先确定位数,再从最高位至最低位逐位确定

    效果比二分好很多

    而且不容易错

  • 0
    @ 2009-01-27 22:45:00

    ……喝了1375牌纯净水后,感觉好极了3rd

  • 0
    @ 2008-11-11 15:34:53

    高精度练手题……

  • 0
    @ 2008-11-08 12:18:22

    晕,数组开小了,要大一点...

  • 0
    @ 2008-11-08 10:22:01

    编译通过...

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

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

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

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

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

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

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

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

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

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

    开始设p与n位数相同,然后逐位确定。

    procedure llll;

    begin

    k:=length(n);

    初始化p为k个0;

    for i:=1 to k do

    begin

    repeat

    p[i]:=succ(p[i]);

    if p[i]>9 then break;

    until p^3+p^2+3*p>n;

    p[i]:=pred(p[i]);

    end;

    end;

  • 0
    @ 2008-11-01 11:18:59

    编译通过...

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

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

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

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

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

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

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

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

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

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

    AC掉的第100题

    注意0,1,2,3,4是0,非常阴险

  • 0
    @ 2008-10-14 20:51:00

    栽在n=0 上面了

  • 0
    @ 2008-09-26 19:22:52

    逐位逼近。以上:(

  • 0
    @ 2008-09-21 17:23:13

    二分答案,但是题目说了正整数,可是第一个数却给了我们0...

  • 0
    @ 2008-09-07 09:32:20

    高精度+二分枚举=ac

    118题,纪念一下!

  • 0
    @ 2008-08-25 11:17:07

    这难度。。。

    我。。———》》

    踩踩踩  踩踩踩  踩踩踩   踩踩踩踩踩踩

    踩踩  踩踩   踩踩   踩踩   踩踩踩踩踩踩

    踩踩                  踩踩踩

         踩踩踩踩踩踩踩踩踩踩踩踩

       踩踩踩踩踩踩踩踩踩踩踩踩踩踩踩踩

     踩踩踩踩踩踩踩踩踩踩踩踩踩踩踩踩踩踩踩

    踩踩踩踩踩踩踩踩踩踩踩踩踩踩踩踩踩踩踩踩

    踩踩踩踩踩踩踩踩踩踩踩踩踩踩踩踩踩踩踩

    踩踩踩踩踩踩踩踩踩踩踩踩踩踩踩踩踩踩

     踩踩踩踩踩踩踩踩踩踩踩踩踩踩踩

     踩踩踩踩踩踩踩踩踩踩踩踩踩

      踩踩踩踩踩踩踩踩踩踩

       踩踩踩踩踩踩踩

       踩踩踩踩踩踩

       踩踩踩踩踩踩

       踩踩踩踩踩踩

        踩踩踩踩踩踩

       踩踩踩踩踩踩踩

      踩踩踩踩踩踩踩踩

     踩踩踩踩踩踩踩踩踩

     踩踩踩踩踩踩踩踩踩踩

     踩踩踩踩踩踩踩踩踩踩

    踩踩踩踩踩踩踩踩踩

      踩踩踩踩踩踩踩踩

       踩踩踩踩踩踩

  • 0
    @ 2008-08-04 15:12:15

    ttt

    曹操

    叼啥?

    编译通过...

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

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

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

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

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

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

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

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

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

信息

ID
1375
难度
6
分类
高精度 | 其他 | 二分查找 点击显示
标签
(无)
递交数
1174
已通过
339
通过率
29%
被复制
4
上传者