Cod sursa(job #218534)

Utilizator funkydvdIancu David Traian funkydvd Data 2 noiembrie 2008 14:07:47
Problema Factorial Scor 0
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.44 kb
#include <fstream>
using namespace std;
ifstream f1 ("fact.in");
ofstream f2 ('fact.out");
int main()
{
long int j,n,p,i,s,f,m;
f1>>p; f1.close();
if (p>0)
   {f=0;
    i=p;
    while (i>=p-(p/5) )
     {j=i;
      n=5*j;
      s=0;
      m=n;
      while (m!=0) {m=m/5; s=s+m;}
      if (s==p)
	 {f2<<n; f=1;}
      i--;
     }
     if (f==0) f2<<"-1";
   }
  else f2<<"1"; f2.close();}