Pagini recente » Cod sursa (job #2708839) | Cod sursa (job #1412501) | Cod sursa (job #2397923) | Cod sursa (job #507550) | Cod sursa (job #821576)
Cod sursa(job #821576)
#include <cstdio>
using namespace std;
int zero(int x)
{
int z=0;
while(x>=1)
{
x/=5;
z+=x;
}
return z;
}
int main()
{
freopen("fact.in","r",stdin);
freopen("fact.out","w",stdout);
int p;
int mid;
int st,dr;
st=0;
dr=(1<<31)-1;
scanf("%d",&p);
if(p==0)
{
printf("1");
return 0;
}
bool ok=true;
while(st<=dr && ok)
{
mid=(st+dr)/2;
if(zero(mid) == p)
ok=false;
else
if(zero(mid)<p)
st=mid+1;
else
dr=mid-1;
}
if(ok)
printf("-1");
else
{
while(mid%5)
--mid;
printf("%d",mid);
}
return 0;
}