Cod sursa(job #1090837)

Utilizator stoicastefanstoica stefan stoicastefan Data 23 ianuarie 2014 09:51:18
Problema Factorial Scor 10
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.4 kb
#include <fstream>
using namespace std;
ifstream f("fact.in");
ofstream g("fact.out");
int fact(long a)
{
	int s=1;
	while(a>=2)
	{
		s*=a;a--;
	}
	return s;
}
int main()
{
	long n,p,i,a=0,aux=0;
	f>>p;
	for(i=1;i<1000000;i++)
	{
		aux=0;
		n=fact(i);
		while(n%10==0){aux++;n=n/10;}
		if(aux==p){a=1;break;a=1;}
	}if(a==1)g<<i;
		else
			g<<-1;
	f.close();g.close();
	return 0;
}