92 条题解

  • 0
    @ 2009-10-09 20:42:34

    第一次写这种高精度,写了81行。。。。。。秒杀

  • 0
    @ 2009-10-06 13:35:18

    编译通过...

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

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

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

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

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

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

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

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

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

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

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

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

    var

    s,ss,n,m:string;

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

    i,j,g,len:integer;

    f:boolean;

    procedure print;

    begin

    fillchar(t,sizeof(t),0);

    if b[len]0 then len:=len+1; g:=0;

    for i:=1 to len do begin

    if a[i]>=b[i]+g then begin

    t[i]:=a[i]-b[i]-g;

    g:=0;

    end else begin

    t[i]:=a[i]+10-b[i]-g;

    g:=1;

    end;

    end;

    if t[len+1]0 then len:=len+1;

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

    for i:=1 to len do begin

    j:=t[i]*2;

    b[i]:=b[i]+j mod 10;

    b:=b+j div 10;

    end;

    if b[len+1]0 then len:=len+1;

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

    fillchar(t,sizeof(t),0); t[1]:=1;

    for i:=1 to len do begin

    j:=b[i]+t[i];

    a[i]:=a[i]+j mod 10;

    a:=j div 10;

    end;

    for j:=len downto 1 do begin

    str(a[j],m);

    n:=n+m;

    end;

    for j:=len downto 1 do if a[j]0 then break;

    delete(n,1,len-j);

    writeln(n);

    end;

    procedure gjd;

    begin

    for i:=1 to len do b[i]:=t[i];

    fillchar(t,sizeof(t),0);

    for i:=1 to len do begin

    j:=b[i]*2;

    t[i]:=t[i]+j mod 10;

    t:=t+j div 10;

    end;

    if t[len+1]0 then len:=len+1;

    if lenlength(s) then f:=true;

    if len=length(s) then begin

    fillchar(ss,sizeof(s),0);

    for i:=len downto 1 do begin

    str(t[i],m);

    ss:=ss+m;

    end;

    if ss>s then f:=true;

    if ss

  • 0
    @ 2009-09-23 07:15:17

    if i mod 2=0 then

    a[i]:=2*a[i div 2]-1

    else a[i]:=2*a[i div 2]+1;

    a[1]:=1;

    这样写对吗??(高精另算)

  • 0
    @ 2009-09-05 19:29:28

    编译通过...

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

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

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

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

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

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

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

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

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

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

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

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

    我囧 高精度尽然交了4次 Orz

  • 0
    @ 2009-08-30 22:12:52

    90多行是不至于啦。。我写了88行。。20分钟1遍AC的高精乘低精。。没什么难度的题。。

    约瑟夫问题有一个很快捷的方法:把读入的n转为2进制,然后把首位的1移到末尾就是答案了。。至于为什么。。大家好好想想吧。。

    晒晒程序:

    type hp=array[0..50] of int64;

    const m=10000;

    var a,b,c:hp;

    function compare(a,b:hp):boolean;

    var i:longint;

    begin

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

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

    if a[i]4 do

    begin

    inc(a[0]);

    val(copy(s,length(s)-3,4),a[a[0]],c);

    delete(s,length(s)-3,4);

    end;

    inc(a[0]);

    val(s,a[a[0]],c);

    end;

    procedure clear(var a:hp);

    var i:longint;

    begin

    for i:=1 to a[0] do

    begin

    inc(a,a[i] div m);

    a[i]:=a[i] mod m;

    end;

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

    end;

    procedure mul(var a:hp);

    var i:longint;

    begin

    for i:=1 to a[0] do

    a[i]:=a[i] shl 1;

    inc(a[0]);

    clear(a);

    end;

    procedure prework;

    var i:longint;

    begin

    c[0]:=1; c[1]:=1;

    while compare(a,c) do

    begin

    b:=c;

    mul(c);

    end;

    end;

    procedure print(a:hp);

    var i:longint;

    begin

    write(a[a[0]]);

    for i:=a[0]-1 downto 1 do

    begin

    if a[i]

  • 0
    @ 2009-08-22 15:44:36

    话说怎么都那么长的程序?

    我才99行……还敲了至少5行的多余回车……

    无语……代码短小也是一种品德!

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

    编译通过...

    ├ 测试数据 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-08-21 17:55:11

    注意细节,注意变量名!

    AC率啊

  • 0
    @ 2009-08-14 14:29:31

    program express(input,output);

    var

    a1:array[1..1000] of ansistring;

    b1:array[1..1000] of char;

    o,l,e,i,j,k,p,m,n,w,s,x,z,c,v:longint;

    st,st1,st2:ansistring;

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

    begin

    if a>b then max:=a else max:=b;

    end;

    function add(st1,st2:ansistring):ansistring;

    var

    st3:ansistring;

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

    i,j,k,l,c,d,e,w,q,s,len:longint;

    begin

    add:='';

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

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

    a[0]:=length(st1);

    b[0]:=length(st2);

    if a[0] mod 4=0 then

    a[0]:=a[0] div 4

    else

    a[0]:=a[0] div 4+1;

    if b[0] mod 4=0 then

    b[0]:=b[0] div 4

    else

    b[0]:=b[0] div 4+1;

    for i:=1 to a[0]-1 do

    val(copy(st1,length(st1)-i*4+1,4),a[i]);

    val(copy(st1,1,length(st1)-(a[0]-1)*4),a[a[0]]);

    for i:=1 to b[0]-1 do

    val(copy(st2,length(st2)-i*4+1,4),b[i]);

    val(copy(st2,1,length(st2)-(b[0]-1)*4),b[b[0]]);

    len:=max(a[0],b[0]);

    for i:=1 to len do

    begin

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

    a:=a+a[i] div 10000;

    a[i]:=a[i] mod 10000;

    end;

    if a[len+1]>0 then inc(len);

    str(a[len],st3);

    add:=add+st3;

    for i:=len-1 downto 1 do

    begin

    str(a[i],st3);

    if a[i]1) and (c[len]=0) do

    len:=len-1;

    str(c[len],st3);

    mul:=mul+st3;

    for i:=len-1 downto 1 do

    begin

    str(c[i],st3);

    if c[i]

  • 0
    @ 2009-08-13 12:55:49

    提交第2000次纪念一下

    Flag   

    题号   P1095

    类型(?)   数论 / 数值

    通过   538人

    提交   1999次

    通过率   27%

    难度   2

    Flag   Accepted

    题号   P1095

    类型(?)   数论 / 数值

    通过   539人

    提交   2000次

    通过率   27%

    难度   2

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

  • 0
    @ 2009-07-27 11:19:23

    var

    shu1,shu,shu2,cha:array [1..1000] of longint;

    g2,i,j,a,b,c,l,x,y,lz:longint;

    k:char;

    function geshu(c:longint):longint;

    var

    yu,o:longint;

    begin

    l:=lz; o:=0; geshu:=0;

    repeat

    if o=1 then begin l:=l-1; o:=0; end;

    a:=lz-l; yu:=0;

    repeat

    a:=a+1;

    yu:=yu+shu[a];

    if yu=10

    then

    begin

    if x=l then l:=l+1;

    shu1[x+1]:=shu1[x+1]+shu1[x] div 10;

    shu1[x]:=shu1[x] mod 10;

    end;

    until x=l;

    end;

    begin

    i:=0;

    while not eoln do

    begin

    i:=i+1;

    read(k);

    shu[i]:=ord(k)-48;

    end;

    lz:=i;

    j:=0;

    for i:=lz downto 1 do

    begin

    j:=j+1;

    shu2[j]:=shu[i];

    end;

    g2:=geshu(1);

    shu1[1]:=1;

    l:=1;

    if g2>=10

    then

    for i:=1 to (g2 div 11) do

    begin

    j:=0;

    repeat

    j:=j+1;

    shu1[j]:=shu1[j]*2048;

    until j=l;

    jingwei;

    end;

    for i:=1 to (g2 mod 11

    ) do

    begin

    j:=0;

    repeat

    j:=j+1;

    shu1[j]:=shu1[j]*2;

    until j=l;

    jingwei;

    end;

    for j:=1 to lz do

    cha[j]:=shu2[j]-shu1[j];

    x:=0;

    repeat

    x:=x+1;

    if cha[x]=10

    then

    begin

    if j=y then y:=y+1;

    cha[j+1]:=cha[j+1]+cha[j] div 10;

    cha[j]:=cha[j] mod 10;

    end;

    until j=y;

    for i:=y downto 1 do

    write(cha[i]);

    end.

  • 0
    @ 2009-07-24 14:24:03

    97行,猥琐啊

    交了两次

    第一次写了一个B:=X

    其实应该是B:=B+X;

    program p1095;

    var n,j:string;

    i,k,l,l1,b,m,s:integer;

    a:array[0..333] of string;

    function mul(s1,s2:string):string;

    var l,i,x,k:integer;

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

    s:string;

    begin

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

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

    l:=length(s2);

    for i:=1 to l do a[l-i+1]:=ord(s2[i])-48;

    for i:=1 to l do

    begin

    x:=a[i]*2;

    if x>=10 then

    begin

    b[i]:=b[i]+x mod 10;

    b:=b+x div 10;

    end else b[i]:=b[i]+x;

    end;

    if b[l+1]0 then k:=l+1 else k:=l;

    mul:='';

    for i:=k downto 1 do

    begin

    str(b[i],s);

    mul:=mul+s;

    end;

    end;

    function jian(s1,s2:string):string;

    var l1,l2,i:integer;

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

    s:string;

    begin

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

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

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

    l1:=length(s1);l2:=length(s2);

    for i:=1 to l1 do a[l1-i+1]:=ord(s1[i])-48;

    for i:=1 to l2 do b[l2-i+1]:=ord(s2[i])-48;

    for i:=1 to l1 do

    begin

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

    if c[i]l1 then

    begin

    k:=i-1;

    j:=jian(n,a[k]);

    j:=mul('2',j);

    l:=length(j);

    for m:=1 to l-1 do write(j[m]);

    val(j[l],s);

    write(s+1);

    exit;

    end else

    if l=l1 then

    for b:=1 to l do

    if n>a then break

    else if n

  • 0
    @ 2009-07-13 18:22:27

    其实。。。不用压位阿。。。(压位会头大的。。。)

    Num为原数

    Now初始为1

    Repeat

    Temp=Num-Now;

    判断temp和now 如果temp

  • 0
    @ 2009-06-06 20:25:05

    为什么要用高精?

  • 0
    @ 2009-04-26 21:07:20

    编译通过...

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

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

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

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

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

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

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

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

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

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

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

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

    program zk;

    var

    shu1,shu,shu2,cha:array [1..1000] of longint;

    g2,i,j,a,b,c,l,x,y,lz:longint;

    k:char;

    function geshu(c:longint):longint;

    var

    yu,o:longint;

    begin

    l:=lz; o:=0; geshu:=0;

    repeat

    if o=1 then begin l:=l-1; o:=0; end;

    a:=lz-l; yu:=0;

    repeat

    a:=a+1;

    yu:=yu+shu[a];

    if yu=10

    then

    begin

    if x=l then l:=l+1;

    shu1[x+1]:=shu1[x+1]+shu1[x] div 10;

    shu1[x]:=shu1[x] mod 10;

    end;

    until x=l;

    end;

    begin

    i:=0;

    while not eoln do

    begin

    i:=i+1;

    read(k);

    shu[i]:=ord(k)-48;

    end;

    lz:=i;

    j:=0;

    for i:=lz downto 1 do

    begin

    j:=j+1;

    shu2[j]:=shu[i];

    end;

    g2:=geshu(1);

    shu1[1]:=1;

    l:=1;

    if g2>=10

    then

    for i:=1 to (g2 div 11) do

    begin

    j:=0;

    repeat

    j:=j+1;

    shu1[j]:=shu1[j]*2048;

    until j=l;

    jingwei;

    end;

    for i:=1 to (g2 mod 11

    ) do

    begin

    j:=0;

    repeat

    j:=j+1;

    shu1[j]:=shu1[j]*2;

    until j=l;

    jingwei;

    end;

    for j:=1 to lz do

    cha[j]:=shu2[j]-shu1[j];

    x:=0;

    repeat

    x:=x+1;

    if cha[x]=10

    then

    begin

    if j=y then y:=y+1;

    cha[j+1]:=cha[j+1]+cha[j] div 10;

    cha[j]:=cha[j] mod 10;

    end;

    until j=y;

    for i:=y downto 1 do

    write(cha[i]);

    end.

    方法【====================================================】

    首先挂一个1---|300 的表

    找规律

    发现

    2的n次方 都是第1个出去

    2的n次方+1 都是第3个出去

    2的n次方+x 都是第1+2*x个出去

    再用高精度

    注意要压位

    规律如下

    1-0

    2-1

    3-3

    4-1

    5-3

    6-5

    7-7

    2^n---|--1

    2^n+1---|--3

    2^n+x---|---|1+2*x

    数组读入n

    找到小于n 的最大 2的某次方

    n 减 2的某次方

    差乘2+1 为答案

    要用高精度

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

    有个东西叫链表

  • 0
    @ 2009-02-06 13:29:40

    丢脸。。。竟然将100位数看成是100以内的数。。。可以去死了

  • 0
    @ 2008-12-31 16:34:21

    编译通过...├ 测试数据 01:答案正确... 0ms├ 测试数据 02:答案正确... 0ms├ 测试数据 03:答案正确... 0ms├ 测试数据 04:答案正确... 0ms├ 测试数据 05:答案正确... 0ms├ 测试数据 06:答案正确... 0ms├ 测试数据 07:答案正确... 0ms├ 测试数据 08:答案正确... 0ms├ 测试数据 09:答案正确... 0ms├ 测试数据 10:答案正确... 0ms-------------------------Accepted 有效得分:100 有效耗时:0ms数据很弱

  • 0
    @ 2008-12-22 20:57:01

    编译通过...

  • 0
    @ 2008-11-07 09:13:21

    编译通过...

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

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

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

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

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

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

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

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

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

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

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

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

    编1小时,汗,高精度搞半天,郁闷

信息

ID
1095
难度
6
分类
其他 | 数学 点击显示
标签
(无)
递交数
2356
已通过
662
通过率
28%
被复制
14
上传者