Cod sursa(job #51593)

Utilizator mariaciPopa Marius Ionut mariaci Data 15 aprilie 2007 13:59:52
Problema Factorial Scor 25
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.48 kb
#include<fstream.h>
#define InFile "fact.in"
#define OutFile "fact.out"
int p,n,i,j;
int main()
{ ifstream f(InFile);
  f>>p;
  int e2,e5,ok=1;
  e2=e5=0;
  while(ok)
    { i++;
      j=i;
      if(j%2==0)
	while(j%2==0)
	  { j=j/2;
	    e2++;
	  }
      if(j%5==0)
	while(j%5==0)
	  { j=j/5;
	    e5++;
	  }
      if(e2==p && e5>=p || e2>=p && e5==p) ok=0;
    }
  ofstream g(OutFile);
  if(p==0) g<<1;
  else g<<i;
  g.close();
  f.close();
  return 0;
}