Cod sursa(job #134873)

Utilizator bishoppAlex Cristian bishopp Data 12 februarie 2008 15:52:37
Problema Factorial Scor 25
Compilator fpc Status done
Runda Arhiva de probleme Marime 0.74 kb
uses dos;
var f,g:text;
    nr,p,i,j:longint;
    ok:boolean;
    o,m,s,su:word;

function putere(x:longint):byte;
var put:byte;
begin
put:=0;
while x mod 5=0 do begin
         x:=x div 5;
         inc(put);
         end;
putere:=put;
end;

begin
settime(0,0,0,0);
ok:=true;
assign(f,'fact.in');reset(f);
assign(g,'fact.out');rewrite(g);
readln(f,p);
i:=0;
nr:=0;
while i<>p do begin
           inc(nr,5);
           inc(i,putere(nr));
           if i>p then begin
                       write(g,'-1');
                       ok:=false;
                       i:=p;
                       end;
           end;
if ok then writeln(g,nr);
close(f);
close(g);
gettime(o,m,s,su);
writeln(o,' ',m,' ',s,' ',su);
readln;
end.