比赛 |
20101105 |
评测结果 |
AAAAAAAAAA |
题目名称 |
火星上的加法运算 |
最终得分 |
100 |
用户昵称 |
wo shi 刘畅 |
运行时间 |
0.000 s |
代码语言 |
Pascal |
内存使用 |
0.00 MiB |
提交时间 |
2010-11-05 19:44:52 |
显示代码纯文本
const
ch: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');
num: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,l1,l2:longint;
s,s1,s2:string;
a,b,c:array[0..1000]of longint;
procedure init;
var
i,l:longint;
begin
readln(n);
readln(s1);
readln(s2);
l1:=length(s1);
l2:=length(s2);
if l1<l2 then
begin
l:=l1;
l1:=l2;
l2:=l;
s:=s1;
s1:=s2;
s2:=s;
end;
for i:=1 to l1 do
begin
if s1[i] in ['0'..'9'] then val(s1[i],a[l1-i+1])
else a[l1-i+1]:=num[s1[i]];
end;
for i:=1 to l2 do
begin
if s2[i] in ['0'..'9'] then val(s2[i],b[l2-i+1])
else b[l2-i+1]:=num[s2[i]];
end;
end;
procedure jia;
var
i:longint;
begin
for i:=1 to l1 do
begin
c[i+1]:=c[i+1]+((a[i]+b[i]+c[i]) div n);
c[i]:=((a[i]+b[i]+c[i]) mod n);
end;
if c[l1+1]>0 then inc(l1);
end;
procedure print;
var
i:longint;
begin
for i:=l1 downto 1 do
begin
if c[i]<10 then write(c[i])
else write(ch[c[i]]);
end;
writeln;
end;
begin
assign(input,'madition.in'); reset(input);
assign(output,'madition.out'); rewrite(output);
init;
jia;
print;
close(input);
close(output);
end.