Cod sursa(job #214949)
| Utilizator | Data | 17 octombrie 2008 00:18:17 | |
|---|---|---|---|
| Problema | Factorial | Scor | 0 |
| Compilator | c | Status | done |
| Runda | Arhiva de probleme | Marime | 0.64 kb |
#include<stdio.h>
int main()
{
FILE *in, *out;
int N=1, i=1, j, P, c2=0, c5=0, nrz=0;
in=fopen("fact.in", "r");
out=fopen("fact.out", "w");
fscanf(in, "%d", &P);
while (nrz<P)
{
j=i;
while (j%2==0)
{
j/=2; c2++;
}
while (j%5==0)
{
j/=5; c5++;
}
nrz=(c2<c5)?c2:c5;
N=N*i;
i++;
}
if(!nrz) fprintf(out, "%d", -1);
else fprintf(out, "%d", N);
fcloseall();
return 0;
}
