Pagini recente » Cod sursa (job #2315068) | Cod sursa (job #1848972) | Cod sursa (job #2266929) | Cod sursa (job #2257232) | Cod sursa (job #118770)
Cod sursa(job #118770)
#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= pow(5,p);
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);
fin.close();
fout.close();
return 0;
}