Cod sursa(job #24092)
Utilizator | razyelx razyelx | Data | 1 martie 2007 20:22:26 |
---|---|---|---|
Problema | Factorial | Scor | 25 |
Compilator | cpp | Status | done |
Runda | Arhiva de probleme | Marime | 0.51 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){
if(p<=100){
i=5;k=0;
while(k<p){
aux=i;
while(aux%5==0){
aux/=5;k++;
}
i+=5;
}
}
if(p>100){
i=25;k=0;
while(k<p){
aux=i;
while(aux%25==0){
aux/=25;k+=2;
}
}
i+=25;
}
if(k==p)
if(p>100)
g<<i-255;
else
g<<i-5;
else
g<<-1;
}else
g<<1;
f.close();
g.close();
return 0;
}