Cod sursa(job #223944)

Utilizator ghedany92Gheorghita Daniel ghedany92 Data 29 noiembrie 2008 16:57:50
Problema Factorial Scor 25
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.43 kb
#include<fstream.h>
int main()
{ifstream fin("fact.in");
ofstream fout("fact.out");
long aux,nr2,nr5,n,p,nr0;
fin>>p; n=0; nr0=0;nr2=0;nr5=0;
if (p>0)
while (nr0<p)
 {n++;
 aux=n;
  while (aux%5==0)
   {nr5++;
    aux=aux/5;
   }
  while (aux%2==0)
   {nr2++;
    aux=aux/2;
   }
  if (nr2<nr5) nr0=nr2;
  if (nr5<nr2) nr0=nr5;
  if (nr5==nr2) nr0=nr2;
}
else n=1;
fout<<n;
fin.close();
fout.close();
return 0;
}