我的高精度乘法为什么不对?

program Agent;

const

k=10000;

type

bignum=array[0..20000]of longint;

var

t1,t2:ansistring;

a,b,c:bignum;

procedure init;

var

i,x,y:longint;

begin

readln(t1);

readln(t2);

end;

procedure mul(a,b:bignum;var c:bignum);

var

i,x,y:longint;

begin

c[0]:=a[0]+b[0]-1;

for x:= 1 to a[0] do

for y:= 1 to b[0] do

inc(c[x+y-1],a[x]*b[y]);

for i:= 1 to c[0] do

begin

inc(c,c[i] div k);

c[i]:=c[i] mod k;

end;

while c[c[0]+1]>0 do

begin

inc(c[0]);

inc(c[c[0]+1],c[c[0]] div k);

c[c[0]]:=c[c[0]] mod k;

end;

end;

procedure main;

var

i,x,y,w:longint;

t:ansistring;

begin

x:=0;t:='';

for i:=length(t1) downto 1 do

begin

inc(x);t:=t1[i]+t;

if x=4 then

begin

x:=0;

val(t,w,w);

t:='';

inc(a[0]);a[a[0]]:=w;

end;

end;

if t'' then

begin

val(t,w,w);

inc(a[0]);

a[a[0]]:=w;

end;

x:=0;t:='';

for i:=length(t2) downto 1 do

begin

inc(x);t:=t2[i]+t;

if x=4 then

begin

x:=0;

val(t,w,w);

t:='';

inc(b[0]);b[b[0]]:=w;

end;

end;

if t'' then

begin

val(t,w,w);

inc(b[0]);

b[b[0]]:=w;

end;

mul(a,b,c);

end;

procedure print;

var

i,x,y:longint;

begin

write(c[c[0]]);

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

begin

if c[i]

0 条评论

目前还没有评论...

信息

ID
1040
难度
7
分类
高精度 点击显示
标签
(无)
递交数
16520
已通过
3156
通过率
19%
被复制
24
上传者