Cod sursa(job #270765)

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

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

unsigned int k[MAX_SIZE];


uint 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 zr=0;    //numarul de zerouri
	int x=0;
	do
	{
		x++;
		if(x%5!=0)
		{
			zr++;
			k[x]=1;
		}
		else
		{
			k[x]=k[x/5]+1;
			zr+=k[x];
		}
		cout<<x<<" "<<k[x]<<endl;
	}while(zr<n);

	//x--;


	if(zr==n)
		g<<(x*5);
	else
		g<<-1;
}
inline void citire()
{
	std::ifstream f("fact.in");
	f>>n;
	f.close();
}