Cod sursa(job #368758)

Utilizator crysysdeaconu ioan crysys Data 25 noiembrie 2009 19:47:42
Problema Factorial Scor 15
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.44 kb
#include<fstream.h>
int main()   
{   
ifstream f("fact.in");   
ofstream g("fact.out");   
 long long p,n,i,j,a,b;
 f>>p;
 int gasit=0;
 n=1;
 while(gasit==0)
 {
  a=b=0;
  for(i=1;i<=n;i++)
   {
    j=i;
    while(j%2==0)
    {
     j=j/2;
     a++;
    }
    j=i;
    while(j%5==0)
    {
     j=j/5;
     b++;
    }
   }
  if(a>b)
     a=b;
  if(a==p)
  {
   gasit=1;
   g<<n;
   }
   n++;
  }
 return 0;   
}