Pagini recente » Cod sursa (job #1301940) | Cod sursa (job #399764) | Cod sursa (job #3041748) | Profil Robybrasov | Cod sursa (job #433521)
Cod sursa(job #433521)
#include<cstdio>
#include<fstream>
using namespace std;
int p;
int bun(int x)
{
int cont=0;
//while(x%5) --x;
while(x)
{
int aux=x;
int contlocal=0;
while(aux%5==0) { aux/=5; ++contlocal; }
cont+=contlocal;
--x;
}
if(cont>=p) return 1;
return 0;
}
int main()
{
ifstream fin("fact.in");
freopen("fact.out","w",stdout);
fin>>p;
int s=0,d=100000000,m;
int rez=-1;
while(s<=d)
{
m=(s+d)>>1;
if(bun(m))
{
rez=m;
d=m-1;
}
else s=m+1;
}
printf("%d\n",rez);
return 0;
}