Cod sursa(job #859317)

Utilizator wallyMocanu Valentin wally Data 20 ianuarie 2013 05:06:46
Problema Factorial Scor 25
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.64 kb
#include<stdio.h>
#include<time.h>

using namespace std;

int main()
{
	clock_t t;
	t = clock();
	long long sol, p, i=0, n=0, k=0, ver;
	FILE *ifp, *ofp;
	ifp = fopen("fact.in", "r");
	ofp = fopen("fact.out", "w");
	
	fscanf(ifp, "%Ld", &p);
	
	///printf ("%Ld", p);
	
	for (i=1;i<=p;i++)
	{
		n=n+5;
		ver = -1;
		k=n;
		while(k%5==0 && k>0)
		{
			ver++;
			k=k/5;
		}
		i = i+ver;
		//cout<<i<<" "<<n<<"\n";
	}
	i--;
	
	if (p==0)
		fprintf(ofp, "%d", 1);
	else
		if (i>p)
			fprintf(ofp, "%d", -1);
		else
			fprintf(ofp, "%Ld", n);
			
	t = clock()-t;
	printf ("%f", ((float)t)/CLOCKS_PER_SEC);
	return 0;
}