Pagini recente » Cod sursa (job #1492914) | Cod sursa (job #3204964) | Cod sursa (job #2833914) | Cod sursa (job #3262956) | Cod sursa (job #433530)
Cod sursa(job #433530)
#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;
}
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;
}