Pagini recente » Cod sursa (job #1320946) | Cod sursa (job #2311577) | Cod sursa (job #1047244) | Cod sursa (job #2361730) | Cod sursa (job #388418)
Cod sursa(job #388418)
#include<iostream>
#include<fstream.h>
using namespace std;
ifstream fin("fact.in");
ofstream fout("fact.out");
long long st,dr,p,mij,ct,i,aux,minim=200000000;
int main()
{
fin>>p;
st=0;
dr=20000000050;
while(st<dr)
{
mij=(st+dr)/2;
aux=mij;
while(aux!=0)
{
ct+=aux/5;
aux/=5;
}
if(p>ct)
{
st=mij+1;
ct=0;
}
if(p<ct)
{
dr=mij-1;
ct=0;
}
if(ct==p && p!=5 && mij<minim)
minim=mij;
}
if(p==5)
fout<<"-1";
else
fout<<minim;
return 0;
}