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