Cod sursa(job #85692)

Utilizator GavrilaVladGavrila Vlad GavrilaVlad Data 22 septembrie 2007 12:51:39
Problema Factorial Scor 90
Compilator fpc Status done
Runda Arhiva de probleme Marime 1.29 kb
var n,i,p:int64;
    f:text;
begin
   i:=0;
   p:=0;
   assign(f,'fact.in');
   reset(f);
   read(f,n);
   close(f);
   assign(f,'fact.out');
   rewrite(f);
   if n=0 then writeln(f,1)
   else
   begin
   while p+305175781<=n do
   begin
   i:=i+1220703125;
   p:=p+305175781;
   end;
   while p+61035156<=n do
   begin
   i:=i+244140625;
   p:=p+61035156;
   end;
   while p+61035156<=n do
   begin
   i:=i+244140625;
   p:=p+61035156;
   end;
   while p+12207031<=n do
   begin
   i:=i+48828125;
   p:=p+12207031;
   end;
   while p+2441406<=n do
   begin
   i:=i+9765625;
   p:=p+2441406;
   end;
   while p+488281<=n do
   begin
   i:=i+1953125;
   p:=p+488281;
   end;
   while p+97656<=n do
   begin
   i:=i+390625;
   p:=p+97656;
   end;
   while p+19531<=n do
   begin
   i:=i+78125;
   p:=p+19531;
   end;
   while p+3906<=n do
   begin
   i:=i+15625;
   p:=p+3906;
   end;
   while p+781<=n do
   begin
   i:=i+3125;
   p:=p+781;
   end;
   while p+156<=n do
   begin
   i:=i+625;
   p:=p+156;
   end;
   while p+31<=n do
   begin
   i:=i+125;
   p:=p+31;
   end;
   while p+6<=n do
   begin
   i:=i+25;
   p:=p+6;
   end;
   while p+1<=n do
   begin
   i:=i+5;
   p:=p+1;
   end;
   end;
   writeln(f,i);


   close(f);
end.