比赛 |
20101105 |
评测结果 |
AAAAAAAAAA |
题目名称 |
火星上的加法运算 |
最终得分 |
100 |
用户昵称 |
donny |
运行时间 |
0.000 s |
代码语言 |
Pascal |
内存使用 |
0.00 MiB |
提交时间 |
2010-11-05 19:19:32 |
显示代码纯文本
program madition;
var
n,i,j,k,l:longint;
a,b,c:string;
f1,f2,f3:array[1..256]of longint;
nn:longint;
ss:set of char;
function ch(x:char):longint;
begin
if x in ss then
exit(ord(x)-ord('0'))
else exit(ord(x)-ord('a')+10);
end;
procedure jia;
var
i,j,q:longint;
begin
q:=0;
for i:=1 to k do
begin
f3[i]:=f1[i]+f2[i]+q;
q:=f3[i] div n;
f3[i]:=f3[i] mod n;
end;
if q<>0 then
begin
k:=k+1;
f3[k]:=q;
end;
end;
function bian(x:longint):char;
begin
if x<10 then
exit(chr(x+ord('0')))
else exit(chr(x-10+ord('a')));
end;
begin
assign(input,'madition.in');
reset(input);
assign(output,'madition.out');
rewrite(output);
readln(n);
ss:=['0','1','2','3','4','5','6','7','8','9'];
readln(a);
readln(b);
for i:=1 to length(a) do
f1[length(a)-i+1]:=ch(a[i]);
for i:=1 to length(b) do
f2[length(b)-i+1]:=ch(b[i]);
k:=length(a);
l:=length(b);
if k<l then k:=l;
jia;
for i:=1 to k do
c[i]:=bian(f3[i]);
for i:=k downto 1 do
write(c[i]);
writeln;
close(input);
close(output);
end.