Cod sursa(job #156167)
| Utilizator | Data | 12 martie 2008 13:18:19 | |
|---|---|---|---|
| Problema | Factorial | Scor | 50 |
| Compilator | cpp | Status | done |
| Runda | Arhiva de probleme | Marime | 0.42 kb |
#include<stdio.h>
long int n,p,aux,x=0,i=0;
int c,c1;
int main ()
{
FILE*f=fopen("fact.in","r");
FILE*g=fopen("fact.out","w");
fscanf(f,"%ld",&p);
if (p==0) fprintf(g,"1");
else {
while (x<p)
{i=i+5;aux=i;
while (aux)
{if (aux%5==0) {x++;aux=aux/5;}
else break;}
}
if (x==p) fprintf(g,"%ld",i);
else fprintf(g,"-1");
}
fclose(f);
fclose(g);
return 0;
}
