Cod sursa(job #162910)
Utilizator | Data | 20 martie 2008 21:42:04 | |
---|---|---|---|
Problema | Factorial | Scor | 50 |
Compilator | cpp | Status | done |
Runda | Arhiva de probleme | Marime | 0.55 kb |
#include <stdio.h>
int main(){
unsigned long p,k,i,aux;
FILE*f=fopen("fact.in","r");
FILE*g=fopen("fact.out","w");
fscanf(f,"%ld",&p);
if(p>0){
i=5;k=0;
while(k<p){
aux=i;
while(aux%5==0){
aux/=5;k++;
}
i+=5;
}
if(k==p)
fprintf(g,"%ld",i-5);
else
fprintf(g,"-1");
}else
fprintf(g,"1");
return 0;
}