Pagini recente » Cod sursa (job #2462011) | Cod sursa (job #114622) | Cod sursa (job #2122150) | Cod sursa (job #1592725) | Cod sursa (job #1603794)
#include <iostream>
#include <fstream>
using namespace std;
int zero(int n)
{int nr=0;
while(n>=5)
{nr=nr+n/5;
n=n/5;
}
return nr;
}
int main()
{long li,ls,k,p,minim,gasit;
fstream f("fact.in",ios::in);
fstream g("fact.out",ios::out);
f>>p;
li=1;
ls=2e9;
gasit=1;
while((li<=ls)&&(gasit==1))
{
k=(li+ls)/2;
if(zero(k)==p)
gasit=0;
if(zero(k)<p)
li=k+1;
else
ls=k-1;
}
if(zero(k)==p)
{while(k%5!=0)
k--;
g<<k;}
else
g<<-1;
}