Cod sursa(job #24215)
Utilizator | razyelx razyelx | Data | 1 martie 2007 21:52:22 |
---|---|---|---|
Problema | Factorial | Scor | 20 |
Compilator | cpp | Status | done |
Runda | Arhiva de probleme | Marime | 0.49 kb |
#include <fstream.h>
int main(){
unsigned long p,k,i,aux;
ifstream f("fact.in");
ofstream g("fact.out");
f>>p;
if(p>0){
i=0;
if(p>100){
i=25;
while(p>100){
aux=i;
while(aux%25==0){
aux/=25;p-=4;
}
i+=25;
}
}
if(!i)i=5;
else
i-=25;
k=0;
while(k<p){
aux=i;
while(aux%5==0){
aux/=5;k++;
}
i+=5;
}
if(k==p)
g<<i-5;
else
g<<-1;
}else
g<<1;
f.close();
g.close();
return 0;
}