2017.6.4测试 题一 k好数

var
 s:string;
 n,k,i,j,t,p,ans:longint;
begin
 readln(n,k);
 for i:=1 to n do
  begin
   p:=0;
   str(i,s);
   for j:=1 to length(s) do//每一位
    if ord(s[j])-48>k then begin//如果有一位大于就退出
                            p:=1;//标记
                            break;
                           end;
   if p=0 then inc(ans);//没有就加1
  end;
 writeln(ans);
end.

相关文章: