Cod sursa(job #47211)

Utilizator cheery_g1rlHaller Emanuela cheery_g1rl Data 3 aprilie 2007 14:11:20
Problema Cifre Scor 40
Compilator fpc Status done
Runda Arhiva de probleme Marime 0.47 kb
var f,g:text;
    a,b,c,k,x,y,i,pos,fav,p:longint;
begin
assign(f,'cifre.in');
reset(f);
readln(f,a,b,c,k);
close(f);
assign(g,'cifre.out');
rewrite(g);
pos:=b-a+1;
fav:=0;
p:=1;
for i:=2 to k do
   p:=p*10+1;
if p>a then a:=p;
for i:=a to b do
   begin
     x:=0;
     y:=i;
     while y<>0 do
        begin
          if y mod 10=c then inc(x);
          y:=y div 10;
        end;
      if x>=k then inc(fav);
   end;
writeln(g,fav/pos:12:4);
close(g);
end.