Cod sursa(job #36041)

Utilizator RobytzzaIonescu Robert Marius Robytzza Data 22 martie 2007 21:27:16
Problema Factorial Scor 45
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.33 kb
#include<fstream.h>
int main(){
ifstream fin("fact.in");
ofstream fout("fact.out");
long int  P,nr,x=0,N=0;
fin>>P;
if (P==0)
   fout<<1;
   else
   while (N!=P){
	 x+=5;
	 nr=x;
	while (nr%5==0){
	       nr/=5;
	       N++;}
	  }
if (N!=P||P<0)
fout<<-1;
else
fout<<x;
fin.close();
fout.close();
return 0;
}