Cod sursa(job #198925)
| Utilizator | Data | 16 iulie 2008 10:11:34 | |
|---|---|---|---|
| Problema | Factorial | Scor | 10 |
| Compilator | cpp | Status | done |
| Runda | Arhiva de probleme | Marime | 0.49 kb |
#include <stdio.h>
#include <math.h>
int main()
{
freopen("fact.in", "r", stdin);
long P;
scanf("%ld", &P);
fclose(stdin);
freopen("fact.out", "w", stdout);
if (P==0) printf("%d",1);
else {long j=1, i=2;
while(j%(long)pow(5,P)) {j=j*i;i++;}
if((j/(long)pow(5,P))%5) printf("%d",i-1);
else printf("%ld", -1);
}
fclose(stdout);
return 0;
}
