记录编号 | 21210 | 评测结果 | AAAAAAAAAA | ||
---|---|---|---|---|---|
题目名称 | 火星上的加法运算 | 最终得分 | 100 | ||
用户昵称 | 是否通过 | 通过 | |||
代码语言 | Pascal | 运行时间 | 0.001 s | ||
提交时间 | 2010-11-08 19:08:37 | 内存使用 | 0.11 MiB | ||
program madition(input,output); var la,lb,ll:longint; a,b:array[1..200]of longint; n:longint; i,k:longint; s1,s2:string; begin assign(input,'madition.in'); reset(input); readln(n); readln(s1); readln(s2); close(input); la:=length(s1); lb:=length(s2); for i:=1 to la do begin if ('0'<=s1[la-i+1])and(s1[la-i+1]<='9') then a[i]:=ord(s1[la-i+1])-ord('0'); if ('a'<=s1[la-i+1])and(s1[la-i+1]<='z') then a[i]:=ord(s1[la-i+1])-ord('a')+10; end; for i:=1 to lb do begin if ('0'<=s2[lb-i+1])and(s2[lb-i+1]<='9') then b[i]:=ord(s2[lb-i+1])-ord('0'); if ('a'<=s2[lb-i+1])and(s2[lb-i+1]<='z') then b[i]:=ord(s2[lb-i+1])-ord('a')+10; end; if la>lb then ll:=la else ll:=lb; k:=0; for i:=1 to ll do begin a[i]:=a[i]+b[i]+k; k:=a[i] div n; a[i]:=a[i] mod n; end; la:=ll; if k>0 then begin a[ll+1]:=k; la:=ll+1; end; assign(output,'madition.out'); rewrite(output); for i:=la downto 1 do begin if (a[i]>=0)and(a[i]<=9) then write(a[i]) else if (a[i]>=10) then write(chr(a[i]-10+ord('a'))); end; close(output); end.