Cod sursa(job #921140)

Utilizator ocpodariuPodariu Ovidiu ocpodariu Data 20 martie 2013 19:59:35
Problema Factorial Scor 35
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.33 kb
#include<fstream>
using namespace std;
int log5(int x){
int exp=0;
if(x==0) return 1;
else{
	while(x%5==0 && x!=0) {x/=5; exp++;}
	return exp;
    }
}
int main(){
ifstream f("fact.in");
ofstream g("fact.out");
int p,nrz=0,x=0;
f>>p;
while(nrz<p){x+=5;
nrz=nrz+log5(x);
}
if(p==0) g<<1;
else if(nrz==p) g<<x;
else g<<-1;
//g<<nrz;
return 0;
}