Cod sursa(job #270461)

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

typedef unsigned int uint;
const unsigned int MAX_SIZE=16252928;

unsigned int v[MAX_SIZE];
uint k;
uint n;
uint pozk;
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;

	pozk=1;

	do
	{
		x++;
		if(x%5==0)
		{
			pozk++;
			k=pozk;
		}
		else
		{
			k=1;
		}
		v[x]=v[x-1]+k;
	}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();
}