Cod sursa(job #118781)
| Utilizator | Data | 27 decembrie 2007 20:07:52 | |
|---|---|---|---|
| Problema | Factorial | Scor | 5 |
| Compilator | cpp | Status | done |
| Runda | Arhiva de probleme | Marime | 0.59 kb |
#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;
}
