Pagini recente » Cod sursa (job #999474) | Cod sursa (job #213286) | Cod sursa (job #897227) | Cod sursa (job #704265) | Cod sursa (job #118781)
Cod sursa(job #118781)
#include<fstream.h>
#include<math.h>
ifstream fin ("fact.in");
ofstream fout("fact.out");
unsigned long int a, b, p, i, x;
double n, c;
int main()
{
fin>>p;
b= 5*(p+1);
int gasit = 0;
do{
c=(a+b)/2;
n = c/5;
i = 1;
x = pow(5,i);
while(x<=c)
{
n+=i-1;
x = pow(5,++i);
}
if(p == n)//5
{
gasit = 1;
fout << c;
}
else
if(n>p)
b = c;
else
a=c;
}while(!gasit && b>=a);
if(!gasit)
fout<<-1;
fin.close();
fout.close();
return 0;
}