Cod sursa(job #397759)
Utilizator | HoriaC HoriaClement | Data | 17 februarie 2010 13:51:07 |
---|---|---|---|
Problema | Factorial | Scor | 100 |
Compilator | cpp | Status | done |
Runda | Arhiva de probleme | Marime | 0.44 kb |
#include <cstdio>
int n;
int zero(int x)
{
int rez=0;
while(x)
{
rez+=x/5;
x/=5;
}
return rez;
}
int caut(int p)
{
int i,pas=1<<30;
for(i=0;pas;pas>>=1)
if(zero(i+pas)<p)
i+=pas;
return i+1;
}
void afis()
{
if(zero(caut(n))==n)
printf("%d",caut(n));
else
printf("-1");
}
int main()
{
freopen("fact.in","r",stdin);
freopen("fact.out","w",stdout);
scanf("%d",&n);
afis();
return 0;
}