记录编号 70223 评测结果 AAAAAA
题目名称 增强的减法问题 最终得分 100
用户昵称 Gravatar翟佳麒 是否通过 通过
代码语言 Pascal 运行时间 0.002 s
提交时间 2013-09-25 13:41:51 内存使用 5.89 MiB
显示代码纯文本
program p38;
var
a,b,c:array[1..999999] of integer;
t,n1,n2:string;
lena,lenb,lenc,i:integer;
begin
assign(input,'sub.in');
reset(input);
assign(output,'sub.out');
rewrite(output);
readln(n1);
readln(n2);
if (length(n1)<length(n2))or((length(n1)=length(n2))and(n1<n2))then
begin
t:=n1;
n1:=n2;
n2:=t;
write('-');
end;
lena:=length(n1);
lenb:=length(n2);
for i:=1 to lena do
a[i]:=ord(n1[lena-i+1])-ord('0');
for i:=1 to lenb do
b[i]:=ord(n2[lenb-i+1])-ord('0');
i:=1;
while i<=lena do
begin
if a[i]<b[i] then
begin
a[i]:=a[i]+10;
a[i+1]:=a[i+1]-1;
end;
c[i]:=a[i]-b[i];
inc(i);
end;
lenc:=i;
while (c[lenc]=0) and (lenc>1) do
dec(lenc);
for i:=lenc downto 1 do
write(c[i]);
writeln
end.