Cod sursa(job #270549)

Utilizator robigiirimias robert robigi Data 4 martie 2009 09:51:31
Problema Factorial Scor 5
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.43 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++)
     {   nr5=cifre5(i);
	 if (nr5>x) { g << -1; ok=0; }
	 else if (nr5==x) { g << i; ok=0; }
     }
}

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