Cod sursa(job #585156)

Utilizator Alexxino7Alexandru Popescu Alexxino7 Data 28 aprilie 2011 10:21:30
Problema Factorial Scor 55
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.38 kb
#include<fstream>
using namespace std;

int main(){
	ifstream fin ("fact.in");
	ofstream fout ("fact.out");
	int N,i=1,nr,j=0;
	fin>>N;
	if(N==0){
		fout<<1<<"\n";
		goto here;}
	while(j<N){
		nr=5*i;
		while(nr%5==0)
			j++,nr/=5;
                i++;
	}
	if(j==N)
		fout<<5*(i-1)<<"\n";
	else
		fout<<-1<<"\n";
	here:
	fin.close();
	fout.close();
	return 0;
}