Cod sursa(job #327589)
| Utilizator | Data | 29 iunie 2009 15:28:07 | |
|---|---|---|---|
| Problema | Factorial | Scor | 0 |
| Compilator | cpp | Status | done |
| Runda | Arhiva de probleme | Marime | 0.48 kb |
#include<cstdio>
#define N 1000000000
int n;
void citire()
{
freopen("factorial.in","r",stdin);
freopen("factorial.out","w",stdout);
scanf("%d",&n);
}
int zero(int x)
{
int r=0;
while (x)
{
x/=5;
r+=x;
}
return r;
}
int caut()
{
int st=1,dr=N;
while (st!=dr)
{
int m=(st+dr)/2;
if (zero(m)>=n)
dr=m;
else
st=m+1;
}
if (zero(st)!=n)
return -1;
return st;
}
int main()
{
citire();
printf("%d",caut());
return 0;
}
