Cod sursa(job #271733)

Utilizator robigiirimias robert robigi Data 5 martie 2009 21:44:48
Problema Factorial Scor 35
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.45 kb
#include <fstream.h>

ifstream f ("fact.in");
ofstream g ("fact.out");


long x;

long cifre5(long n)
{    int nr=0;
     while (n%5==0)
     {     nr++;
	   n/=5;
     }
     return nr;
}

void program()
{    f >> x;
     int ok=1, nr5=0;
     for (long i=2; ok; i++)
     {	 if (nr5>x) { g << -1; ok=0; }
	 else if (nr5==x) { g << i-1; ok=0; }
	      else nr5+=cifre5(i);
     }
}

int main()
{   program();
    return 0;
}