Cod sursa(job #386556)
Utilizator | Data | 25 ianuarie 2010 10:53:16 | |
---|---|---|---|
Problema | Factorial | Scor | 10 |
Compilator | cpp | Status | done |
Runda | Arhiva de probleme | Marime | 0.37 kb |
#include <iostream>
using namespace std;
#include <fstream>
using namespace std;
int main()
{ fstream f,g;
f.open("fact.in",fstream::in);
g.open("fact.out",fstream::out);
long int p,a,r,ax={0};
f>>p;
a=p*5;
r=5;
ax=a;
while (r*5<a){
r*=5;
if (r==ax){
a=-1;
break;
}
a-=5;
}
if (p==0) g<<1;
else g<<a;
g.close();
return 0;
}