Pagini recente » Cod sursa (job #2486121) | Cod sursa (job #1644711) | Cod sursa (job #346869) | Cod sursa (job #1372303) | Cod sursa (job #786632)
Cod sursa(job #786632)
#include <fstream>
using namespace std;
ifstream fin("fact.in");
ofstream fout("fact.out");
long long int n, st, dr, p, c, nrz;
long long int numarzerouri(int x)
{
int i=0;
while(x)
{
x/=5;
i+=x;
}
return i;
}
int main()
{
fin>>p;
if(p==0) fout<<1;
else
{
st=0;
dr=1000000000;
n=1;
if(p>0){
while(n){ c=(st+dr)/2;
nrz=numarzerouri(c);
if(nrz==p&&st==dr) {n=st;break;}
if(dr<st) {n=-1;break;}
if(p>nrz) st=c+1;
else dr=c-1;
}
}
fout<<n;
}
}