Pagini recente » Cod sursa (job #2879308) | Cod sursa (job #2882226) | Cod sursa (job #2664309) | Cod sursa (job #458209) | Cod sursa (job #412478)
Cod sursa(job #412478)
#include<fstream>
#include<iostream>
#include<math.h>
using namespace std;
ifstream f("fact.in");
ofstream g("fact.out");
int n;
unsigned long long p;
long nrz1( long c )
{
long x = 0;
while( c )
{
x += c/5;
c /= 5;
}
return x;
}
int bin()
{
int low,high,mid;
low = 1;
high = 10000000000LL;
while (low < high) {
mid = low + ((high - low) / 2);
if (nrz1(mid)< p)
low = mid + 1;
else
high = mid;
}
if ((low < 10000000000LL) && (nrz1(low) == p))
return low;
else
return -1;
}
int main()
{
f>>p;
g<<bin()<<endl;
f.close();
g.close();
return 0;
}