# 高精乘

135人阅读 评论(0)

var

i,j,la,lb,len:integer;

s1,s2:string;

m:longint;

a,b,c:array[1..250] of integer;

begin

readln(s1);

la:=length(s1);

readln(s2);

lb:=length(s2);

for i:=1 to la do

a[i]:=ord(s1[la-i+1])-48;

for i:=1 to lb do

b[i]:=ord(s2[lb-i+1])-48;

for i:=1 to la do

for j:=1 to lb do

c[i+j-1]:=c[i+j-1]+a[i]*b[j];

len:=la+lb;

for i:=1 to len do

begin

c[i+1]:=c[i+1]+c[i] div 10;

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

end;

while c[len]=0 do dec(len);

m:=c[len];

while m>0 do

begin

c[len]:=m mod 10;

m:=m div 10;

inc(len);

end;

for i:=len-1 downto 1 do

write(c[i]);

writeln;

end.

SIZE = 200+10;

Type

hugeint = Record

len : Integer;

num : Array[1..SIZE] Of int64;

End;

var a:hugeint;

s1:string;

i:integer;

x:longint;

procedure lowmul(a:hugeint;x:longint);

var

i:longint;

ans:hugeint;

begin

fillchar(ans.num,sizeof(ans.num),0);

ans.len:=a.len;

for i:=1 to ans.len do ans.num[i]:=a.num[i]*x;

for i:=1 to ans.len do

begin

inc(ans.num[i+1],ans.num[i] div 10);

ans.num[i]:=ans.num[i] mod 10;

end;

while ans.num[ans.len+1]>0 do

begin

inc(ans.len);

inc(ans.num[ans.len+1],ans.num[ans.len] div 10);

ans.num[ans.len]:=ans.num[ans.len] mod 10;

end;

for i:=ans.len downto 1 do write(ans.num[i]);

writeln;

end;

procedure datain;

begin

assign(input,'lowmul.in');  assign(output,'lowmul.out');

reset(input); rewrite(output);

readln(s1);

readln(x);

a.len:=length(s1);

for i:=1 to a.len do  a.num[i]:=ord(s1[a.len-i+1])-ord('0');

end;

begin

datain;

lowmul(a,x);

close(input);close(output);

end.
0
0

* 以上用户言论只代表其个人观点，不代表CSDN网站的观点或立场
个人资料
• 访问：16285次
• 积分：119
• 等级：
• 排名：千里之外
• 原创：91篇
• 转载：0篇
• 译文：0篇
• 评论：0条
文章分类
文章存档
阅读排行
评论排行