Pagini recente » Cod sursa (job #141287) | Cod sursa (job #3240567) | Cod sursa (job #2387038) | Cod sursa (job #2163700) | Cod sursa (job #490434)
Cod sursa(job #490434)
#include<cstdio>
using namespace std;
int p;
int nr_zero(int x)
{
int rez=0;
while(x)
{
rez+=x/5;
x/=5;
}
return rez;
}
int caut_bin(int y)
{
int i,pas=1<<30;
for (i=0;pas;pas >>= 1)
if (nr_zero(i+pas)< p)
i+=pas;
return i + 1;
}
int main()
{
int p;
freopen("fact.in","r",stdin);
freopen("fact.out","w",stdout);
scanf("%d",&p);
if(nr_zero(caut_bin(p))==p)
printf ("%d",caut_bin(p));
else
printf ("-1");
return 0;
}