Cod sursa(job #821410)

Utilizator axnsanCristi Vijdea axnsan Data 22 noiembrie 2012 13:28:28
Problema Factorial Scor 55
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.54 kb
#include <fstream>
//#include <iostream>
//#include <ctime>
using namespace std;
#define cout g
int c[13];
int main()
{
	int P,beg,end;
	//beg = clock();
	ifstream f("fact.in");
	ofstream g("fact.out");
	f >> P;
	if (P == 0)
	{
		cout << 0 << endl;
		return 0;
	}
	int Z(0);
	while (Z < P)
	{
		int i(1);
		++Z;
		++c[1];
		while (c[i]%5 == 0)
		{
			++c[++i];
			++Z;
		}
	}
	//end = clock();
	if (Z != P) cout << -1 << endl;
	else cout << c[1]*5 << endl;
	//cout << (end-beg)*1.0/CLOCKS_PER_SEC;
	//cin.get();
}