Cod sursa(job #780049)
| Utilizator | Data | 19 august 2012 19:00:38 | |
|---|---|---|---|
| Problema | Factorial | Scor | 15 |
| Compilator | cpp | Status | done |
| Runda | Arhiva de probleme | Marime | 0.64 kb |
#include <fstream>
#include <math.h>
using namespace std;
int numZero(long x){
int k=0,q=1;
while(x/pow(5,q)){
k+=x/pow(5,q);
q++;
}
return k;
}
int main()
{long p,k;int a;
ifstream f("fact.in");
ofstream g("fact.out");
f>>p;
f.close();
k=2*p;
if(p<numZero(k)){
while(numZero(k)){
k--;
a=numZero(k);
}
}else {
while(p!=numZero(k)){
k++;
a=numZero(k);
}
}
if(!p)
g<<1;
else{if(p==a)
g<<k;
else
g<<-1;}
g.close();
return 0;
}
