Cod sursa(job #42332)

Utilizator nod_softwareBudisteanu Ionut Alexandru nod_software Data 29 martie 2007 09:17:23
Problema Factorial Scor 15
Compilator fpc Status done
Runda Arhiva de probleme Marime 0.76 kb
program NOD_SOFTWARE;
type vector = array [1..100] of integer;
var v:vector;
    n2,n5,i,j,n,m,p:integer;
    fin,fout:text;
{*----------MAIN*-------------*}
begin
     assign(fin,'fact.in');
     assign(fout,'fact.out');
     reset(fin);
     rewrite(fout);
     readln(fin,p);
     if p = 0 then write(fout,1)
     else
     begin
     i:=1;
     n2:=0;
     n5:=0;
     repeat
           j:=i;
           while j mod 2 = 0 do
           begin
                inc(n2);
                j:=j div 2;
           end;
           while j mod 5 = 0 do
           begin
                inc(n5);
                j:=j div 5;
           end;
           inc(i);
     until (n2>=p) and (n5>=p);
     writeln(fout,i-1);
     end;
     close(fout);
end.