Cod sursa(job #391657)
| Utilizator | Data | 6 februarie 2010 00:24:19 | |
|---|---|---|---|
| Problema | Factorial | Scor | 100 |
| Compilator | cpp | Status | done |
| Runda | Arhiva de probleme | Marime | 0.5 kb |
#include <cstdio>
unsigned long N;
unsigned long nrzerouri(unsigned long x)
{
unsigned long c=5,rez=0;
while(c<=x)
{
rez+=x/c;
c*=5;
}
return rez;
}
unsigned long cautbin()
{
unsigned long p=1<<31,a=0;
while(p)
{
if(nrzerouri(a+p)<N)
a+=p;
p>>=1;
}
if(nrzerouri(a+1)==N)
return a+1+1;
else
return 0;
}
int main()
{
freopen("fact.in","r",stdin);
freopen("fact.out","w",stdout);
scanf("%u",&N);
printf("%d",cautbin()-1);
return 0;
}
