将m进制数n转化成一个十进制数 m<=16
题目保证转换后的十进制数<=100
var
s:string;n,ans:longint;
procedure init;
begin
readln(s);
val(copy(s,pos(' ',s)+1,length(s)-pos(' ',s)),n);
delete(s,pos(' ',s),length(s)-pos(' ',s)+1);
end;
procedure main;
var
i,j:longint;
begin
j:=1;
for i:=length(s) downto 1 do
begin
if ord(s[i])-48>10 then
begin
ans:=ans+j*(ord(s[i])-55);
j:=j*n;
end
else
begin
ans:=ans+j*(ord(s[i])-48);
j:=j*n;
end;
end;
writeln(ans);
end;
begin
init;
main;
end.