Cod sursa(job #359309)

Utilizator bocacristiBoca Nelu Cristian bocacristi Data 26 octombrie 2009 16:02:54
Problema Factorial Scor 5
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.44 kb
#include <fstream>
#include <math.h>
using namespace std;

int main()
{
	long int p = 0;
	ifstream fin("fact.in");
	ofstream fout("fact.out");
	fin >> p;
	
	long int max = p * 5;
	long int nr = 0;
    for (long int i = 25; i < max; i += 5)
        if (i % 25 == 0)
		{
			int j = i /5;
			while ( j % 5 == 0)
			{
				nr++;
				j /= 5;
			}
		}
	
	p -= nr;
	fout << p * 5;
	
 	fout.close();
	fin.close();

	return 0;
}