Pagini recente » Cod sursa (job #3269969) | Cod sursa (job #127933) | Cod sursa (job #403498) | Cod sursa (job #2613897) | Cod sursa (job #433570)
Cod sursa(job #433570)
#include<cstdio>
#include<fstream>
using namespace std;
int p;
int bun(int x)
{
int cont=0;
int putere=5;
while(x>=putere)
{
cont+=(x/putere);
putere*=5;
}
if (cont>=p) return 1;
return 0;
}
int main()
{
ifstream fin("fact.in");
//freopen("fact.out","w",stdout);
ofstream fout("fact.out");
fin>>p;
unsigned long long s=0,d=1<<31,m;
unsigned long long rez=0;
if(p==0) { fout<<1; return 0; }
else
while(s<=d)
{
m=(s+d)>>1;
if(bun(m))
{
rez=m;
d=m-1;
}
else s=m+1;
}
//printf("%lld\n",rez);
if(rez) fout<<rez;
else fout<<-1;
return 0;
}