题目: |
program sx201603;
var a:array[0..8] of longint;
ans,i,t,len:longint;
s:string;
begin
readln(t);
a[0]:=1;
for i:=1 to 8 do
a[i]:=a[i-1]*t;
readln(s);
len:=length(s);
ans:=0;
for i:=len downto 1 do
if s[i]= ’0’ then ans:=ans+a[len-i];
writeln(ans);
end.
输入:5
10010
输出:151
|