Cod sursa(job #136729)
Utilizator | Data | 15 februarie 2008 20:52:20 | |
---|---|---|---|
Problema | Factorial | Scor | 40 |
Compilator | cpp | Status | done |
Runda | Arhiva de probleme | Marime | 0.5 kb |
#include <stdio.h>
FILE* f;
int main()
{
int p;
int zecimale=0;
f=fopen ("fact.in","r");
fscanf (f,"%d",&p);
fclose (f);
int i=5;
while (zecimale<p)
{
int j=i;
while (j%10==0)
{
zecimale++;
j=j/10;
}
while (j%5==0)
{
zecimale++;
j=j/5;
}
i+=5;
}
f=fopen ("fact.out","w");
if (zecimale==p)
{
if (p!=0)
fprintf (f,"%d",i-5);
else
fprintf (f,"%d",1);
}
else
fprintf (f,"%d",-1);
fclose (f);
return 0;
}