Cod sursa(job #134310)

Utilizator ghitza_2000Stefan Gheorghe ghitza_2000 Data 11 februarie 2008 12:21:34
Problema Factorial Scor 0
Compilator fpc Status done
Runda Arhiva de probleme Marime 0.43 kb
var i,p,n,ct,ct1,ct2:longint;
    f,g:text;
begin
assign(f,'fact.in'); reset(f);
assign(g,'fact.out'); rewrite(g);
readln(f,p);  ct1:=0;  ct2:=0; ct:=0; n:=1;
while ct<p do
begin
n:=n+1;
for i:=1 to n do
begin
 while (i mod 2)=0 do
 begin
 inc(ct1);
 i:=i div 2;
 end;
 while i mod 5=0 do
 begin
 inc(ct2);
 i:=i div 2;
 end;
end;
if ct1>ct2 then ct:=ct2
else ct:=ct1;
end;
write(g,n);
close(f); close(g);
end.