Pagini recente » Cod sursa (job #228370) | Cod sursa (job #209675) | Istoria paginii runda/ice_2 | Mihnea Andreescu | Cod sursa (job #221271)
Cod sursa(job #221271)
#include<fstream.h>
fstream f,g;
long p,n,i,k;
long nrdiv5(long x);
int main(){
f.open("fact.in",ios::in);
f>>p;
f.close();
g.open("fact.out",ios::out);
if(p==0){
n=1;
g<<n;
g.close();
}
else{
n=0;
k=0;
while(k<p){
n=n+5;
k=k+nrdiv5(n);
}
if(k==p)
g<<n;
else
g<<-1;
g.close();
}
return 1;
}
long nrdiv5(long x){
long s=0;
while(x%5==0){
s++;
x=x/5;
}
return s;
}