我知道估计没人解答,我自己看了都长的程序

program gamee(input,output);

type arty=array[-10..100] of integer;

var b,c,ans:array[-10..100] of arty;

f:array[-10..100,-10..100] of arty;

a,h1,h2:arty;

ll,l,v,jj,i,j,n,m:integer;

procedure change(i,t:integer);

begin

if t=10 then

begin

c[i][j+1]:=c[i][j] div 10+c[i][j+1];

c[i][j]:=c[i][j] mod 10;

if j+1>c[i][0] then c[i][0]:=j+1;

end;

end;

procedure mutiply(a,b:arty;var c:arty);

var x,i,j,lena,lenb:integer;

begin

lena:=a[0]; lenb:=b[0];

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

for i:=1 to lena do

begin

x:=0;

for j:=1 to lenb do

begin

c:=a[i]*b[j]+c+x;

x:=c div 10;

c:=c mod 10;

end;

if x0 then c:=c+x;

end;

c[0]:=lena+lenb;

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

end;

procedure add(a,b:arty;var c:arty);

var lena,lenb,i,j:integer;

begin

lena:=a[0]; lenb:=b[0];

i:=1;

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

while (i

3 条评论

  • @ 2014-09-08 15:08:01

    还好,66行
    type
    arr=array[0..30]of longint;
    var
    a:array[0..81,0..81]of arr;
    b:array[0..81]of longint;
    er:array[0..80]of arr;
    i,j,k,l,m,n:longint;
    big,ans:arr;
    function max(a,b:arr):arr;
    var o:longint;
    begin
    for o:=30 downto 1 do
    begin
    if a[o]>b[o]then exit(a);
    if a[o]<b[o]then exit(b);
    end;
    exit(a);
    end;
    function jia(a,b:arr):arr;
    var o:longint;
    begin
    for o:=1 to 30 do
    jia[o]:=a[o]+b[o];
    for o:=2 to 30 do
    begin
    inc(jia[o],jia[o-1]div 10);
    jia[o-1]:=jia[o-1]mod 10;
    end;
    end;
    function cheng(a:arr;b:longint):arr;
    var o,p,ta,tb:longint;
    begin
    fillchar(cheng,sizeof(cheng),0);
    ta:=30;
    while a[ta]=0 do dec(ta);
    for o:=1 to ta do
    cheng[o]:=a[o]*b;
    for o:=2 to ta+3 do
    begin
    inc(cheng[o],cheng[o-1]div 10);
    cheng[o-1]:=cheng[o-1]mod 10;
    end;
    end;
    begin
    read(m,n);
    er[0][1]:=1;
    for i:=1 to 80 do
    er[i]:=cheng(er[i-1],2);
    for i:=1 to m do
    begin
    for j:=1 to n do
    read(b[j]);
    fillchar(a,sizeof(a),0);
    for j:=n-2 downto 0 do
    for k:=1 to n-j do
    a[k,j+k]:=max(jia(a[k,j+k+1],cheng(er[n-j-1],b[j+k+1])),
    jia(a[k-1,j+k],cheng(er[n-j-1],b[k-1])));
    fillchar(big,sizeof(big),0);
    for j:=1 to n do
    big:=max(big,jia(a[j,j],cheng(er[n],b[j])));
    ans:=jia(ans,big);
    end;
    l:=30;
    while(ans[l]=0)and(l<>0)do dec(l);
    if l=0 then write(0)else for i:=l downto 1 do write(ans[i]);
    end.

  • @ 2009-09-15 21:41:00

    = =我的还好。80+行

    type arr=array[0..10]of longint;

    const maxm=80;maxt=10000;

    var n,m,ii,j,i,y:longint;

    a:array[0..maxm]of arr;

    f:array[0..maxm,0..maxm]of arr;

    two:array[0..80]of arr;

    twotwo,ans,tot:arr;

    function cheng(a,b:arr):arr;

    var i,j,lena,lenb,len:longint;

    c:arr;

    begin

    lena:=a[0];lenb:=b[0];

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

    for i:=1 to lena do

    for j:=1 to lenb do

    begin

    c:=c+a[i]*b[j];

    c:=c+c div maxt;

    c:=c mod maxt;

    end;

    len:=lena+lenb-1;

    while c[len+1]>0 do inc(len);

    c[0]:=len;exit(c);

    end;

    function jia(a,b:arr):arr;

    var i,len:longint;

    begin

    len:=a[0];if b[0]>len then len:=b[0];

    for i:=1 to len do

    begin

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

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

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

    end;

    while a[len+1]>0 do inc(len);

    a[0]:=len;exit(a);

    end;

    procedure init_two;

    var i:longint;

    begin

    two[0][1]:=1;two[0][0]:=1;twotwo[1]:=2;twotwo[0]:=1;

    for i:=1 to m do

    two[i]:=cheng(two,twotwo);

    end;

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

    var i:longint;

    begin

    if a[0]>b[0] then exit(a);

    if a[0]b[i] then exit(a);

    if a[i]=1)and(tot[i] div j=0) do

    begin

    write('0');

    j:=j div 10;

    end;

    write(tot[i]);

    end;

    end.

  • @ 2009-07-12 21:16:18

    我的也很长

    幸好AC了

    type

    arr=array [0..200] of longint;

    var

    a :array [1..90] of qword;

    f :array [0..90,1..90] of arr;

    sh :array [0..100] of arr;

    h,g :arr;

    n,t,k,m :qword;

    sum :arr;

    p,i,j :longint;

    function jia(b,c :arr):arr;

    var i,j,x,len :longint;

    begin

    x:=0;for i:=b[0]+1 to b[0]+30 do b[i]:=0;

    for i:=c[0]+1 to c[0]+30 do c[i]:=0;

    if b[0]>c[0] then len:=b[0] else len:=c[0];

    for i:=0 to len+2 do jia[i]:=0;

    for i:=1 to len do

    begin

    x:=b[i]+c[i]+x;

    jia[i]:=x mod 10;

    x:=x div 10;

    end;

    jia[0]:=len;

    if x>0 then

    begin

    jia[len+1]:=x;

    inc(jia[0]);

    end;

    end;

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

    var i :longint;

    begin

    if a[0]>b[0] then exit(a);

    if a[0]b[i] then exit(a);

    if a[i]0 then

    begin

    while x>0 do

    begin

    inc(mutiply[0]);

    mutiply[mutiply[0]]:=x mod 10;

    x:=x div 10;

    end;

    end;

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

    exit(mutiply);

    end;

    function sh1(k :longint):arr;

    var i :longint;sh :arr;

    begin

    {fillchar(sh,sizeof(sh),0);}

    for i:=0 to k do sh[i]:=0;

    sh[0]:=1;sh[1]:=1;

    for i:=1 to k do

    sh:=mutiply1(2,sh);

    exit(sh);

    end;

    procedure print;

    var k :longint;

    begin

    writeln('len : ',i,' start : ',j,'***|');

    for k:=f[i][j][0] downto 1 do write(f[i][j][k]);writeln;

    end;

    procedure main;

    begin

    sum[0]:=0;

    readln(k,n);

    for p:=1 to k do

    begin

    for i:=1 to n do read(a[i]);readln;

    for i:=1 to n do

    for j:=1 to n-i+1 do

    begin

    h:=jia(f,mutiply1(a[j+i-1],sh[n-i+1]));

    g:=jia(f,mutiply1(a[j],sh[n-i+1]));

    f:=max(h,g);

    // print;

    end;

    sum:=jia(sum,f[n,1]);

    end;

    for i:=sum[0] downto 1 do write(sum[i]);

    if sum[0]=0 then write(0);

    end;

    procedure ready;

    var i :longint;

    begin

    for i:=1 to 100 do sh[i]:=sh1(i);

    end;

    begin

    ready;

    main;

    end.

  • 1

信息

ID
1378
难度
7
分类
动态规划 | 高精度 点击显示
标签
递交数
4669
已通过
1056
通过率
23%
被复制
9
上传者