Cod sursa(job #368885)

Utilizator crysysdeaconu ioan crysys Data 26 noiembrie 2009 12:59:54
Problema Factorial Scor 25
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.59 kb
#include<fstream.h>
int main()   
{   
ifstream f("fact.in");   
ofstream g("fact.out");   
 long long p,n,min,j,a,b;
 f>>p;
 int gasit=0;
 n=0;
 a=b=0;
 if(p==5)
 g<<"-1";
 else
 if(p==0)
  g<<"1";
  else
 while(gasit==0)
 {
   n=n+5;
   /*j=n;
    while(j%2==0)
    {
     j=j/2;
     a++;
    }  */
    j=n;
    while(j%5==0 && j!=0)
    {
     j=j/5;
     b++;
    }    
/*  if(a>b)
  min=b;
  else  */
  min=b;
    if(min==p)
      {
        gasit=1;
	 g<<n;
     }
     else
      if(min>p)
      {
       gasit=1;
	g<<"-1";
       }
  }
 return 0;
}