40 条题解

  • 0
    @ 2008-11-10 11:46:38

    晕...公布的标程在我的电脑上用cena测,竟然第5个点超时

    改宽限制后,1.02秒出解...

    我的电脑不会这么烂吧...

    我的程序比标程快 不过第五个点还是0.4秒

  • 0
    @ 2008-11-10 09:54:09

    求第二组数据,我很奇怪的无输出

    求第五组数据,MY GOD我超时

  • 0
    @ 2008-11-10 09:46:15

    #include

    #include

    #define maxlen 100000

    long n,k[maxlen+10],len[maxlen+10],min[maxlen+10],max[maxlen+10];

    void num_minus_be_long(long *c,long a)

    {

    long i,len,has;

    len=c[0];

    c[1]-=a;

    c[len+1]=0;

    while(1)

    {

    has=0;

    for(i=1;i

  • 0
    @ 2008-11-10 09:39:33

    编译通过...

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

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

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

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

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

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

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

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

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

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

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

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

    谁能说下第5个点0ms的方法。。。

    我的方法是:

    设函数f(k)=(n-3)*2^k+3*(k+1)-n,读入k',找到f(k-1)

  • 0
    @ 2008-11-10 09:05:45

    so 8....RP……

  • 0
    @ 2008-11-09 19:29:35

    难得靠下。。。

  • 0
    @ 2008-11-06 11:24:12

    二层地下室

  • 0
    @ 2008-11-04 10:33:10

    地下室

  • 0
    @ 2008-10-25 09:36:54

    门槛

  • 0
    @ 2008-10-19 15:46:01

    地板

  • -1
    @ 2016-05-20 01:25:42

    题解+代码

    测试数据 #0: Accepted, time = 0 ms, mem = 632 KiB, score = 10
    测试数据 #1: Accepted, time = 0 ms, mem = 940 KiB, score = 10
    测试数据 #2: Accepted, time = 0 ms, mem = 940 KiB, score = 10
    测试数据 #3: Accepted, time = 0 ms, mem = 944 KiB, score = 10
    测试数据 #4: Accepted, time = 0 ms, mem = 784 KiB, score = 10
    测试数据 #5: Accepted, time = 0 ms, mem = 940 KiB, score = 10
    测试数据 #6: Accepted, time = 0 ms, mem = 940 KiB, score = 10
    测试数据 #7: Accepted, time = 0 ms, mem = 940 KiB, score = 10
    测试数据 #8: Accepted, time = 0 ms, mem = 936 KiB, score = 10
    测试数据 #9: Accepted, time = 0 ms, mem = 940 KiB, score = 10
    Accepted, time = 0 ms, mem = 944 KiB, score = 100
    打了一个晚上。。终于A了

  • -1
    @ 2016-03-16 17:51:28

    python 完美AC

    \(
    S_1=\left\{1,2, ..., n\right\}\\
    S_2=\left\{3,4, ..., 2n-1\right\}\\
    S_3=\left\{7,8, ..., 4n-3\right\}\\
    ...\\
    S_k=\left\{2^k-1, ..., 2^{k-1}\cdot n-2^{k-1}+1\right\}
    \)

    所以第k个集合的大小等于\((n-3)\cdot 2^{k-1}+3\)
    前k个集合的总大小求和化简后等于\(3k+(n-3)\cdot (2^k-1)\)

    二分目标数处在第几个集合,然后简单运算并输出即可。注意n=1,2或3的情况。

    • @ 2016-04-04 20:25:57

      大侠 能给几组大点的数据吗

    • @ 2016-05-20 01:26:02

      Sk错了

  • -2
    @ 2015-08-12 15:51:39

    反复踩到坑里,不过发现高精压位一定情况下原来存在隐藏的问题(最后两个case输出前后都对,中间却错了),虽然开始cheat,不过终于成功A掉!

  • -2
    @ 2014-07-18 18:42:40

    压位肯定A,如果打不好是技术问题

  • -2
    @ 2013-03-19 22:46:53
  • -2
    @ 2013-03-19 22:39:06

    事实证明**压位**并**不是**好方法

  • -2
    @ 2013-03-19 22:37:35

    用**c++**的童鞋们,都改用**pascal**吧!c++**没人**ac

  • -2
    @ 2009-11-09 21:35:11

    编译通过...

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

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

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

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

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

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

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

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

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

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

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

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

    话说,我写这题那天晚上发烧。。。可能是H6N6吧。

    program sets;

    type

    num = array[0..1020] of int64; //高进制压位

    const

    binary = 1000000000;

    len = trunc(ln(binary)/ln(10));

    maxr = 3322;

    var

    n,i,l,r,mid,q: longint;

    t: int64;

    s: ansistring;

    a,k,a0,di,c: num;

    procedure pluslow(var a:num; k:longint); //高精+低精

    var l: integer;

    begin

    inc(a[1],k);

    l:=1;

    while a[l]>=binary do begin

    inc(a[l+1],a[l] div binary);

    a[l]:=a[l] mod binary;

    inc(l);

    end;

    if l>a[0] then a[0]:=l;

    end;

    procedure plushigh(a,b:num; var c:num); //高精+高精

    var i: integer;

    begin

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

    i:=1;

    while (i1) and (c[c[0]]=0) do dec(c[0]);

    end;

    procedure quickpower(var a:num; k:integer); //2^k的快速幂

    var l,i: integer;

    temp: double;

    begin

    if k=0 then l:=1

    else begin

    temp:=ln(k)/ln(2);

    l:=trunc(temp);

    end;

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

    for i:= l downto 0 do begin

    if k shr i and 1=1 then multlow(a,2);

    if i>0 then multhigh(a,a,a);

    end;

    end;

    function max(a,b:num):boolean; //比较大小

    var i: integer;

    begin

    if a[0]>b[0] then exit(true) else

    if a[0]0) and (a[i]=b[i]) do dec(i);

    if i=0 then exit(true) else

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

    else exit(false);

    end;

    end;

    procedure print(a:num); //输出某个高进制数

    var i,l: integer;

    begin

    l:=a[0];

    write(a[l]);

    for i:= l-1 downto 1 do begin

    t:=binary div 10;

    while t>9 do begin

    if a[i]0 then begin

    inc(l);

    val(copy(s,1,i),k[l]);

    end;

    k[0]:=l;

    if n=2 then begin

    if s='1' then writeln(1) else

    if s='2' then writeln(2) else

    if s='3' then writeln(3) else

    writeln(-1);

    close(input);close(output);

    halt;

    end;

    if n=3 then begin

    val(s,q);

    t:=(q-1) div 3+1;

    quickpower(a0,t);

    subslow(a0,1);

    pluslow(a0,q-(t-1)*3-1);

    print(a0);

    close(input);close(output);

    halt;

    end;

    l:=1; r:=maxr;

    while l

  • -2
    @ 2009-09-13 14:54:29

    啊,神啊,压位压到10000000000000000还是超了,~~~~~~~~~

  • -2
    @ 2009-09-13 12:48:44

    编译通过...

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

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

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

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

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

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

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

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

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

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

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

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

    才356行~~~~0.0

    var //Puppy神 让我秒了吧~~

    s,kk:ansistring;

    lena,lenb,lenc,lend,lene,lenk,lenkk,lenkkk,p,i,n,chen,lenpc,lenans1,len1,len2

    ,len3,len4,len5,len6,lenlp,lennc,lenpp,lenget,aa:longint;

    lp,a6,d,a,k,a1,a2,a3,a4,a5,pc,nc,kkkk,ans1,pp,get:array [0..5000] of int64;

    procedure tp;

    begin

    if n=2 then

    begin

    if kk='1' then

    writeln(1)

    else

    if kk='2' then

    writeln(2)

    else

    if kk='3' then

    writeln(3)

    else

    writeln(-1);

    halt;

    end;

    end;

    {procedure make;

    begin

    lena:=le;

    for i:=1 to length(k) do

    a[i]:=ord(k[lena-i+1])-48;

    end; }

    procedure make(kkk:ansistring);

    var

    pp:longint;

    s:ansistring;

    begin

    fillchar(kkkk,sizeof(kkkk),0);

    lenkkk:=0;

    repeat

    if length(kkk)1) and (d[lend]=0) do dec(lend);

    end;

    procedure gjc;//a1 a2存

    var

    i,j:longint;

    x,x1:int64;

    begin

    for i:=1 to lend+1 do

    d[i]:=0;

    for i:=1 to len1 do

    begin

    x:=0;

    for j:=1 to len2 do

    begin

    x1:=int64(a1[i])*int64(a2[j]);

    x:=x1+x+d;

    d:=x mod 100000000;

    x:=x div 100000000;

    end;

    d:=x;

    end;

    lend:=len1+len2;

    while (lend>1) and (d[lend]=0) do dec(lend);

    end;

    procedure jia;//a3,a4

    var

    i,j:longint;

    x:int64;

    begin

    for i:=1 to lend+1 do

    d[i]:=0;

    x:=0;

    if len3>len4 then lend:=len3 else lend:=len4;

    for i:=1 to lend do

    begin

    x:=a3[i]+a4[i]+x+d[i];

    d[i]:=x mod 100000000;

    x:=x div 100000000;

    end;

    if x>0 then begin inc(lend);d[lend]:=x;end;

    end;

    procedure jian;//a5,a6

    var

    i,j:longint;

    begin

    for i:=1 to lend+1 do

    d[i]:=0;

    if len5>len6 then lena:=len5 else lena:=len6;

    for i:=1 to lena do

    begin

    if a5[i]1) do dec(lend);

    end;

    function big:boolean;//lp,k

    var

    i:longint;

    begin

    if lenlplenk then exit(true);

    for i:=lenlp downto 1 do

    begin

    if lp[i]>k[i] then exit(true);

    if lp[i]9999999 then write(aa) else

    if aa>999999 then write('0',aa) else

    if aa>99999 then write('00',aa) else

    if aa>9999 then write('000',aa) else

    if aa>999 then write('0000',aa) else

    if aa>99 then write('00000',aa) else

    if aa>9 then write('000000',aa) else

    write('0000000',aa);

    end;

    halt;

    end;

    begin

    init;

    make(kk);//压位存入a

    k:=kkkk;

    lenk:=lenkkk;

    tp;//特殊判断

    if n=3 then da

    else

    chen:=doit;

    result1(chen+1);

    get:=a1;

    lenget:=len1;

    a5:=get;

    len5:=lenget;

    fillchar(a6,sizeof(a6),0);

    a6[1]:=1;

    jian;

    lenget:=lend;

    get:=d;

    a6:=ans1;

    len6:=lenans1;

    a5:=k;

    len5:=lenk;

    jian;

    pp:=d;

    lenpp:=lend;

    fillchar(a6,sizeof(a6),0);

    len6:=1;

    a6[1]:=1;

    a5:=pp;

    len5:=lenpp;

    jian;

    pp:=d;

    lenpp:=lend;

    a4:=get;

    len4:=lenget;

    a3:=pp;

    len3:=lenpp;

    jia;

    lenpp:=lend;

    pp:=d;

    write(pp[lenpp]);

    for i:=lenpp-1 downto 1 do

    begin

    aa:=pp[i];

    if aa>9999999 then write(aa) else

    if aa>999999 then write('0',aa) else

    if aa>99999 then write('00',aa) else

    if aa>9999 then write('000',aa) else

    if aa>999 then write('0000',aa) else

    if aa>99 then write('00000',aa) else

    if aa>9 then write('000000',aa) else

    write('0000000',aa);

    end;

    end.

信息

ID
1472
难度
8
分类
其他 | 二分查找高精度 点击显示
标签
递交数
1351
已通过
175
通过率
13%
被复制
5
上传者