Cod sursa(job #1610941)

Utilizator DoubleNyNinicu Cristian DoubleNy Data 23 februarie 2016 20:39:26
Problema Cifre Scor 40
Compilator fpc Status done
Runda Arhiva de probleme Marime 0.87 kb
var A,B,C,K,N,jos,sus,o,u,copya,copyb:longint;






BEGIN
      assign(input,'cifre.in'); reset(input);
      assign(output,'cifre.out'); rewrite(output);
      readln(input,A,B,C,K);
      n:=0;
      o:=0;
      u:=0;
      copya:=a; copyb:=b;
       while A<B do
         begin
             jos:=A; sus:=B;
               while (jos>0) or (sus>0) do
                 begin
                    if (jos>0) and (jos mod 10 = c) then inc(o);
                    jos:=jos div 10;

                    if (sus>0) and (sus mod 10 = c) then inc(u);
                    sus:=sus div 10;

                 end;

              if o>=k then inc(n);
              if u>=k then inc(n);
              o:=0; u:=0;
           inc(a);
           dec(b);
        end;


      write(output,N/((copyb-copya)+1):0:4);
      close(input);
      close(output);
END.