Pagini recente » Cod sursa (job #3279106) | Cod sursa (job #2594299) | Cod sursa (job #482462) | Cod sursa (job #2530388) | Cod sursa (job #2609138)
#include<fstream>
using namespace std;
ifstream f("fact.in");
ofstream g("fact.out");
long long p,st,dr,mij,ok;
int nrzero (int x)
{
int i=5,t=0,k=0;
while(i<=x)
{
k=k+x/i;
i*=5;
}
return k;
}
int main ()
{
f>>p;
if(p==0)
{
g<<1;
return 0;
}
ok=0;
st=1;
dr=5*p;
while(st<=dr)
{
mij=st+(dr-st)/2;
if(nrzero(mij)==p)
ok=1;
if(nrzero(mij)>=p)
dr=mij-1;
else
st=mij+1;
}
if(ok==1)
g<<st;
else
g<<-1;
}