Cod sursa(job #270459)

Utilizator rayvianPricope Razvan rayvian Data 4 martie 2009 00:25:39
Problema Factorial Scor 35
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.65 kb
#include <iostream>
#include <fstream>
using namespace std;


const int MAX_SIZE=8126464;

int v[MAX_SIZE];
int k[MAX_SIZE];
int n;
ofstream g("fact.out");



inline void citire();
inline void add_data();
int main()
{
	citire();

	if(n==0)
	{
		g<<1;
		g.close();
		return 0;
	}

	add_data();

	g.close();
	return 0;
}


inline void add_data()
{
	int x=0;
	do
	{
		x++;
		if(x%5==0)
		{
			k[x]=k[x/5]+1;
		}
		else
		{
			k[x]=1;
		}
		v[x]=v[x-1]+k[x];
	}while(v[x]<=n);

  --x;

	if(v[x]==n)
		g<<x*5;
	else
		g<<-1;


}
inline void citire()
{
	std::ifstream f("fact.in");
	f>>n;
	f.close();
}