- 高精度乘法
- 2013-03-15 23:51:02 @
为什么后面两个点过不了啊
求大神指导
var s1,s2:string;
a,b,ans:array[1..100000]of longint;
i,j,k,l:longint;
begin
readln(s1);
readln(s2);
l:=length(s1)+length(s2);
for i:=length(s1) downto 1 do begin
inc(k);
a[k]:=ord(s1[i])-48;
end;
k:=0;
for i:=length(s2) downto 1 do begin
inc(k);
b[k]:=ord(s2[i])-48;
end;
for i:=1 to length(s1) do
for j:=1 to length(s2) do ans[i+j-1]:=ans[i+j-1]+(a[i]*b[j]);
for i:=1 to l do begin
ans[i+1]:=ans[i+1]+(ans[i] div 10);
ans[i]:=ans[i] mod 10;
end;
while ans[l]=0 do dec(l);
for i:=l downto 1 do write(ans[i]);
if l=0 then write(0);
writeln;
end.
4 条评论
-
琴海忧伤V LV 7 @ 2013-05-10 19:07:35
谢谢
-
2013-05-10 19:07:12@
谢谢了
-
2013-05-05 16:48:05@
高精度不过首要看数据范围
-
2013-05-04 21:53:30@
ansistring
- 1