PASCAL程序求改正

来源:百度知道 编辑:UC知道 时间:2024/05/26 23:51:23
NOIP最大乘积一题,增大数据值域,用高精度做,不知我的程序到底什么问题,麻烦大牛指出

type
numtype=array [0..100] of byte;
var
f:array [0..100,0..10] of numtype;
n:numtype;
s:string;
k,i,j,l:byte;

function catch(p,l:integer):numtype;
var
t:numtype;
m:byte;
begin
t[0]:=l;
for m := 1 to l do t[m]:=n[p+m-1];
exit(t)
end;

function max(x,y:numtype):numtype;
var
o:byte;
begin
if x[0]>y[0] then exit(x);
if x[0]<y[0] then exit(y);
for o := x[0] downto 1 do begin
if x[o]>y[o] then exit(x);
if x[o]<y[o] then exit(y)
end;
exit(x)
end;

function mult(a,b:numtype):numtype;
var
c:numtype;
p:byte;
begin
fillchar(c,sizeof(c),0);
p:=0;
for i := 1 to b[0] do
for j := 1 to a[0] do begin
inc(c[i+j-1],a[j]*b[i]);

给你一个对的:
program NOIP;

var
b:array[1..40,1..6] of extended;
k,long,temp:integer;
n:string;

procedure input;
var
i,j:integer;
begin
readln(long);
readln(k);
readln(n);
for i:=1 to long do
for j:=1 to k do
b[i,j]:=-1;
end;

function check(l,t:integer):extended;
var
i:integer;
j,max:extended;
begin
if t=0 then
begin
val(copy(n,l,long),j,temp);
check:=j;
end
else
begin
if b[l,t]=-1 then
begin
j:=0;max:=0;
for i:=l to long-t do
begin
val(copy(n,l,i-l+1),j,temp);
j:=j*check(i+1,t-1);
if j>max then max:=j;
end;
b[l,t]:=max;
end;
check:=b[l,t];
end;
end;

begin
input;
writeln(check(1,k):0:0);
end.