Cod sursa(job #346707)

Utilizator mihai_r2005Richard Mihai Andrei mihai_r2005 Data 9 septembrie 2009 11:02:28
Problema Factorial Scor 5
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.34 kb
#include <iostream.h>
#include <fstream.h>

int i, p;

int ndiv5(int i)
{
	int ndiv = 1;
	while(i != 1){
		i/=5;
		ndiv++;
	}
	return ndiv;
}

int main()
{
	ifstream fi("fact.in");
	ofstream fo("fact.out");
	fi>>p;
	i = 0;
	while (p > 0){
		i++;
		if (i%5==0)
			p-=ndiv5(i);
		else
			p--;
	}
	fo<<i*5;
	return 0;
}