讨论 / 给我一个解释 给你一堆人品
yrh 2010-10-08 23:06:00
点我顶贴 收藏 删除
调试了3.5个小时 只能过两个点 还不是高精度的 …… 求慧眼识珠大牛 看破我的漏洞(呜呜呜 就是改不出了 帮忙啊);

type

gjd=array[-10..100] of longint;

const

go=10000;

var

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

map,er:array[-10..88] of gjd;

a,temp,ans:gjd;

f:array[-10..88,-10..88] of gjd;

procedure print(a:gjd);

var i:longint;

begin

while a[a[0]]<=0 do

dec(a[0]);

write(a[a[0]]);

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

begin

if a[i]<10 then write('000') else

if a[i]<100 then write('00') else

if a[i]<1000 then write('0');

write(a[i]);

end;

writeln;

end;

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

var i:longint;

begin

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

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

for i:=a[0] downto 1 do

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

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

exit(b);

end;

function cheng(a:gjd; b:longint):gjd;

var i,next:longint;

begin

cheng[0]:=a[0];

next:=0;

for i:=1 to cheng[0] do

begin

cheng[i]:=a[i]*b+next;

next:=cheng[i] div go;

cheng[i]:=cheng[i] mod go;

end;

if next>0 then

begin

inc(cheng[0]);

cheng[cheng[0]]:=next;

end;

end;

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

var i,next:longint;

begin

if a[0]>b[0] then jia[0]:=a[0] else jia[0]:=b[0];

next:=0;

for i:=1 to jia[0] do

begin

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

next:=jia[i] div go;

jia[i]:=jia[i] mod go;

end;

if next>0 then

begin

inc(jia[0]);

jia[jia[0]]:=next;

end;

end;

begin

readln(n,m);

ans[0]:=1;

ans[1]:=1;

er[0]:=ans;

for i:=1 to m do

er[i]:=jia(er[i-1],er[i-1]);

fillchar(ans,sizeof(ans),0);

for i:=1 to n do

begin

for j:=1 to m do

read(map[i,j]);

readln;

end;

for k:=1 to n do

begin

fillchar(f,sizeof(f),0);

a:=map[k];

for i:=1 to m+1 do

for j:=m downto i-1 do

f[i,j]:=max( jia(f[i-1,j] , cheng( er[i-1+m-j] , a[i-1] ) ),

jia(f[i,j+1] , cheng( er[i-1+m-j] , a[j+1] ) ) );

fillchar(temp,sizeof(temp),0);

for i:=1 to m+1 do

temp:=max(temp,f[i,i-1]);

ans:=jia(ans,temp);

end;

print(ans);

end.

#1 王易檀本人@2010-10-08 22:25:00
回复 删除
哪一题?

哪一题?

#2 yrh@2010-10-08 23:06:00
回复 删除
矩阵取数游戏 noip2007 第三题

矩阵取数游戏 noip2007 第三题

查看更多回复
提交回复