Cod sursa(job #382816)
| Utilizator | Data | 14 ianuarie 2010 19:35:22 | |
|---|---|---|---|
| Problema | Factorial | Scor | 10 |
| Compilator | cpp | Status | done |
| Runda | Arhiva de probleme | Marime | 0.66 kb |
#include<stdio.h>
#include<stdlib.h>
int main()
{
int p,q, n=1,fact,c=0;
freopen("fact.in","r",stdin);
freopen("fact.out","w",stdout);
scanf("%d",&p);
int z=1;
for(int i=1;i<=p;i++)
z*=10;
for(int i=1; i<=50000;i++)
{
fact=1;
c++;
for(int j=1; j<=i;j++)
{
fact*=j;
}
if(fact%z==0)
{
q=0;
break;
}
}
if(q==0)
printf("%d",c);
else
printf("-1");
fclose(stdin);
fclose(stdout);
return 0;
}
