十五方水罐车价格:pascal中,如何高效率的用高精度除以高精度(200位以上)?

来源:百度文库 编辑:神马品牌网 时间:2024/04/28 16:10:43

可以一千一千的乘
我这个的范围是10000位
如果需要扩大 可以修改arr1&arr2的大小或者是arr1的integer
program p1040;
type
arr1=array[1..2600] of integer;
arr2=array[1..6000] of qword;
var
a,b:arr1;
c:arr2;
i,j,la,lb,lc:integer;
h,jin:qword;
s:string;

procedure init;
var
i,j:integer;
code:longint;
s:string;
st:ansistring;
begin
readln(st);
j:=0;
i:=length(st);
while i>3 do
begin
inc(j);
s:=copy(st,i-3,4);
val(s,a[j],code);
dec(i,4);
end;
if i<>0 then begin inc(j);s:=copy(st,0,i);val(s,a[j],code);end;
la:=j;
j:=0;
readln(st);
i:=length(st);
while i>3 do
begin
inc(j);
s:=copy(st,i-3,4);
val(s,b[j],code);
dec(i,4);
end;
if i<>0 then begin inc(j);s:=copy(st,0,i);val(s,b[j],code);end;
lb:=j;
end;

begin
init;
for i:=1 to 5000 do c[i]:=0;
jin:=0;
for i:=1 to la do
for j:=1 to lb do
c[i+j-1]:=c[i+j-1]+a[i]*b[j];

for i:=1 to 4999 do
begin
jin:=c[i];
c[i]:=jin mod 10000;
c[i+1]:=c[i+1]+(jin div 10000);
end;

j:=0;
for i:=5000 downto 1 do
begin
if (c[i]<>0)and(j=0) then j:=1;
if (j<>0) then
begin
str(c[i],s);
if j<>1 then write(stringofchar('0',4-length(s)));
write(s);
j:=2;
end;
end;
if j=0 then writeln('0') else writeln;
end.