- 高精度乘法
- 2013-08-26 19:09:55 @
const max=50000;
var
a,b,c:array[1..max] of integer;
n1,n2:string;
lena,lenb,lenc,i,j,x:integer;
begin
readln(n1);
readln(n2);
lena:=length(n1);
lenb:=length(n2);
for i:=1 to lena do a[lena-i+1]:=ord(n1[i])-ord('0');
for i:=1 to lenb do b[lenb-i+1]:=ord(n2[i])-ord('0');
for i:=1 to lena do
begin
x:=0;
for j:=1 to lenb do
begin
c[i+j-1]:=a[i]*b[j]+x+c[i+j-1];
x:=c[i+j-1] div 10;
c[i+j-1]:=c[i+j-1] mod 10;
end;
c[i+j]:=x;
end;
lenc:=lena+lenb;
while (c[lenc]=0) and (lenc>1) do dec(lenc);
for i:=lenc downto 1 do write(c[i]);
end.
6 条评论
-
guoqiting93 LV 8 @ 2013-10-27 15:28:29
a=raw_input()
b=raw_input()
print int(a)*int(b) -
2013-10-27 15:27:44@
数据太大,别纠结
标程只有3行 -
2013-08-27 11:27:06@
呵呵呵呵呵呵呵
-
2013-08-27 10:52:17@
我也没压位,不过只有第四点没过
-
2013-08-27 09:31:03@
n1,n2没有逆序
-
2013-08-26 20:20:18@
怎么可能会过呢
- 1