为什么只有20分?!

P1303 A*B Problem

LRM123 @ 2016-01-04 18:31:52

我就是想不明白,为什么只有20分!?

const max=10000;
var
  a,b,c:array[1..max]of longint;
n1,n2:string;
lena,lenb,lenc,i,j,x:longint;
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[i]+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.

by cbx8888 @ 2016-01-15 20:12:09

没处理进位?


by 噬魂彡Pascal @ 2016-02-03 19:41:36

我也20!!!!!!


by 张瑞祥的pascal @ 2016-10-09 20:45:40

我这60希望能帮你一下

const max=200;
var
    sa,sb:string;
    x:longint;
    a,b:array[1..max] of integer;
    c:array[1..2*max] of integer;
    i,j,la,lb,len:integer;
begin
    readln(sa);readln(sb);
    if (sa='0') or (sb='0') then begin writeln(0);halt;end;
    fillchar(a,sizeof(a),0);
    fillchar(b,sizeof(b),0);
    fillchar(c,sizeof(c),0);
    la:=length(sa);
    for i:=1 to la do
    a[i]:=ord(sa[la-i+1])-48;
    lb:=length(sb);
    for i:=1 to lb do
    b[i]:=ord(sb[la-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    len:=len-1;
    x:=c[len];
    while x>0 do
    begin
        c[len]:=x mod 10;
        x:=x div 10;
        len:=len+1;
    end;
    for i:=len-1 downto 1 do 
    write(c[i]);    
end.

|