Cod sursa(job #266469)

Utilizator wladVlad Mariasiu wlad Data 25 februarie 2009 17:04:52
Problema Cifra Scor 0
Compilator fpc Status done
Runda Arhiva de probleme Marime 0.59 kb
function test(n:integer):integer;
   begin
   test:=0;
    if (n mod 100=25) or (n mod 100=50) or (n mod 100=75) then test:=2
                     else if (n mod 10=5) or (n mod 10=0) then test:=1;
   end;

var i,j,k,c:longint;
begin

assign(input,'fact.in');
assign(output,'fact.out');
reset(input);
rewrite(output);
readln(k);
   c:=0;
 for i:=1 to 99999999 do begin
     c:=c+test(i);
     if c>k then j:=-1;
     if c=k then begin j:=i; break; end;


   end;

   if k=0 then write(1) else write(j);
     readln;

     close(input);
     close(output);
     end.