Cod sursa(job #212241)
| Utilizator | Data | 4 octombrie 2008 20:20:00 | |
|---|---|---|---|
| Problema | Factorial | Scor | 0 |
| Compilator | cpp | Status | done |
| Runda | Arhiva de probleme | Marime | 0.45 kb |
#include<stdio.h>
long p;
long long unsigned i,sol;
int fact(int a)
{
long s=0;
while(a>1)
{a=a/5;
s=s+a;
}
return s;
}
void solve()
{
scanf("%ld",&p);
for(i=0;i<=-1;i=i+5) if(fact(i)>=p){sol=i;break;}
if(fact(sol)!=p) printf("-1")
else if (sol==0) printf("1");
else printf("%ld",sol);
}
int main()
{
freopen("fact.in","r",stdin);
freopen("fact.out","w",stdout);
solve();
return 0;
}