记录编号 78451 评测结果 AAAAAAAAAAAA
题目名称 增强的乘法问题 最终得分 100
用户昵称 GravatarTA 是否通过 通过
代码语言 Pascal 运行时间 0.000 s
提交时间 2013-11-03 22:17:08 内存使用 0.00 MiB
显示代码纯文本
var
 x,y,z:string[100];
 a,b:array[1..100] of shortint;
 ans:array[1..200] of integer;
 i,j,ta,t2,le:byte;
begin
 assign(input,'mul.in');
 assign(output,'mul.out');
 reset(input);
 rewrite(output);
 //while not(eof) do
  //begin
   readln(x);
   readln(y);
   if (x='0') or (y='0') then
     begin
      writeln('0');
      exit;
     end;
   if length(x)<length(y) then
     begin
      z:=x;
      x:=y;
      y:=z;
     end;
   ta:=length(x);
   t2:=length(y);
   fillchar(ans,sizeof(ans),0);
   for i:=1 to ta do
    a[i]:=ord(x[ta-i+1])-48;
   for i:=1 to t2 do
    b[i]:=ord(y[t2-i+1])-48;
   le:=0;
   for i:=1 to t2 do
    for j:=1 to ta do
     begin
      inc(ans[i+j-1],b[i]*a[j]);
      if i+j-1>le then
        le:=i+j-1;
     end;
   i:=0;
   repeat
    inc(i);
    inc(ans[i+1],ans[i] div 10);
    ans[i]:=ans[i] mod 10;
    if (ans[i+1]<>0) and (i+1>le) then
      inc(le);
   until i=le;
   for i:=le downto 1 do
    write(ans[i]);
  //end;
 close(input);
 close(output);
end.