Cod sursa(job #828692)

Utilizator d0rina2011Craciun Dorina d0rina2011 Data 4 decembrie 2012 09:04:59
Problema Factorial Scor 20
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.41 kb
#include<fstream> 
using namespace std; 
ifstream fin("fact.in");
ofstream fout("fact.out"); 
int main () 
{
    int x,p,k=0,n;
    fin >> p;
    n=p*5;
    if(p==0)fout<<"1";
    for (x=5;x<=n;x=x+5)
	{
		n=x;
		while(n%5==0)
		{
			n=n/5;
	        k++;
		}
		if(k==p)fout<<x;
		else 
		{
			if(k>p)fout<<"-1";
			else fout<<"-1";
	    }
    }
    fin.close();
    fout.close();
    return 0;
}