Pagini recente » Cod sursa (job #2252386) | Cod sursa (job #2589468) | Cod sursa (job #2267859) | Cod sursa (job #3136723) | Cod sursa (job #2987704)
#include <fstream>
using namespace std;
ifstream in ("fact.in");
ofstream out ("fact.out");
int verif (long long n)
{
long long fact=5;
int cnt=0;
while(fact<=n)
{
cnt+=n/fact;
fact*=5;
}
return cnt;
}
int main()
{
long long p,st=0,dr=10000000,m,q;
in>>p;
while(st<=dr)
{
m=((st+dr)/2)*5;
q=verif(m);
if(q<p)
st=(m+5)/5;
else if(q>p)
dr=(m-5)/5;
else
{
out<<m;
return 0;
}
}
out<<-1;
return 0;
}