比赛 |
20101105 |
评测结果 |
AAAAAAAAAA |
题目名称 |
火星上的加法运算 |
最终得分 |
100 |
用户昵称 |
Achilles |
运行时间 |
0.000 s |
代码语言 |
Pascal |
内存使用 |
0.00 MiB |
提交时间 |
2010-11-05 19:39:19 |
显示代码纯文本
program madition;
const
a:array[10..35]of char=('a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y',
'z');
b:array['a'..'z']of longint=(10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29
,30,31,32,33,34,35);
var
n,i,l:longint;
s1,s2:string;
c:char;
code:integer;
sz1,sz2:array[0..300]of longint;
begin
fillchar(sz1,sizeof(sz1),0);
fillchar(sz2,sizeof(sz2),0);
assign(input,'madition.in');
assign(output,'madition.out');
reset(input);
rewrite(output);
readln(n);
readln(s1);
readln(s2);
for i:=1 to length(s1)div 2 do
begin
c:=s1[i];
s1[i]:=s1[length(s1)-i+1];
s1[length(s1)-i+1]:=c;
end;
for i:=1 to length(s2)div 2 do
begin
c:=s2[i];
s2[i]:=s2[length(s2)-i+1];
s2[length(s2)-i+1]:=c;
end;
sz1[0]:=length(s1);
for i:=length(s1) downto 1 do
begin
if ('a'<=s1[i])and('a'<=s1[i]) then sz1[i]:=b[s1[i]] else val(s1[i],sz1[i],code);
end;
sz2[0]:=length(s2);
for i:=length(s2) downto 1 do
begin
if ('a'<=s2[i])and('a'<=s2[i]) then sz2[i]:=b[s2[i]] else val(s2[i],sz2[i],code);
end;
if sz1[0]>sz2[0] then l:=sz1[0] else l:=sz2[0];
for i:=1 to l do
begin
sz1[i]:=sz1[i]+sz2[i];
if sz1[i]>=n then begin
sz1[i+1]:=sz1[i+1]+(sz1[i] div n);
sz1[i]:=sz1[i] mod n;
end;
end;
if sz1[l+1]<>0 then l:=l+1;
for i:=l downto 1 do
if (0<=sz1[i])and(sz1[i]<=9) then write(sz1[i]) else write(a[sz1[i]]);
close(input);
close(output);
end.