Cod sursa(job #214954)
Utilizator | Oprea Mihai mihaio07 | Data | 17 octombrie 2008 00:34:22 |
---|---|---|---|
Problema | Factorial | Scor | 0 |
Compilator | c | Status | done |
Runda | Arhiva de probleme | Marime | 0.64 kb |
#include<stdio.h>
//0 2 4 10
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++;
}
if (c2<c5) nrz=c2;
else nrz=c5;
i++;
}
if(!nrz) fprintf(out, "%d", -1);
else fprintf(out, "%ld", i);
return 0;
}