Cod sursa(job #422953)

Utilizator paul_gabryelPaul Buda paul_gabryel Data 23 martie 2010 12:52:39
Problema Factorial Scor 60
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.42 kb
#include<iostream>
#include<fstream>
#include<cstdio>
using namespace std;
int p,c;
int help (int x)
{
	int pp=0;
	while(x%5==0){
		x/=5;
		++pp;
		}
	return pp;
}
int main ()
{
	ifstream fin ("fact.in");
	freopen("fact.out","w",stdout);
	fin>>p;
	int aux=0;
	if(p==0)
	printf("1\n");
	else{
		c=1;
		for(int i=1;i<=p&&c<=p;++i){
			aux+=5;
			c++;
			if(i%5==0)
				c+=help(i);
			}
		
	printf("%d\n",aux);
	}
	
	return 0;
}