Cod sursa(job #284284)
Utilizator | Ciurel Victor CiurelVictor | Data | 21 martie 2009 16:00:25 |
---|---|---|---|
Problema | Factorial | Scor | 75 |
Compilator | c | Status | done |
Runda | Arhiva de probleme | Marime | 0.41 kb |
#include<stdio.h>
int main()
{
long k,p,aux;
int ok;
FILE *f;
FILE *g;
f=fopen("fact.in","r");
g=fopen("fact.out","w");
fscanf(f,"%ld",&p);
k=0;
ok=1;
while(p&&ok)
{
p--;
k++;
aux=k;
while(aux%5==0)
{
p--;
aux=aux/5;
}
if(p<0)
ok=0;
}
if(!ok)
fprintf(g,"-1");
else
{
if(!k)
fprintf(g,"1");
else
fprintf(g,"%ld",(k*5));
}
return 0;
}