比赛 |
20101105 |
评测结果 |
AWAWAWWWWA |
题目名称 |
火星上的加法运算 |
最终得分 |
40 |
用户昵称 |
ZhouZn1 |
运行时间 |
0.000 s |
代码语言 |
Pascal |
内存使用 |
0.00 MiB |
提交时间 |
2010-11-05 19:36:35 |
显示代码纯文本
program zzn;
const
num3:array['0'..'9']of integer=(0,1,2,3,4,5,6,7,8,9);
num2:array['a'..'z']of integer=(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);
num: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');
type
arr=array[0..205]of integer;
var
i,j,n,l:longint;
st:string;
a,b,c:arr;
procedure init;
begin
assign(input,'madition.in');
reset(input);
assign(output,'madition.out');
rewrite(output);
readln(n);
fillchar(a,sizeof(a),0);
fillchar(b,sizeof(b),0);
fillchar(c,sizeof(c),0);
readln(st);
a[0]:=length(st);l:=a[0];
for i:=1 to a[0] do if st[l+1-i] in ['0'..'9']then
a[i]:=num3[st[l+1-i]]
else
a[i]:=num2[st[l+1-i]];
readln(st);
b[0]:=length(st);
l:=b[0];
for i:=1 to b[0] do if st[l+1-i] in ['0'..'9']then b[i]:=num3[st[l+1-i]] else
b[i]:=num2[st[l+1-i]];
end;
procedure closef;
begin
close(input);
close(output);
end;
procedure main;
begin
if a[0]>b[0] then c[0]:=a[0] else c[0]:=b[0];
for i:=1 to c[0] do
begin
c[i]:=c[i]+a[i]+b[i];
c[i+1]:=c[i] div n;
c[i]:=c[i] mod n;
end;
if c[c[0]]>n then
begin
c[c[0]+1]:=c[c[0]]div n;
c[c[0]]:=c[c[0]] mod n;
inc(c[0]);
end;
for i:=c[0] downto 1 do
if c[i]>10 then write(num[c[i]]) else write(c[i]);writeln;
end;
begin
init;
main;
closef;
end.