Cod sursa(job #223927)

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