Pagini recente » Cod sursa (job #2316637) | Cod sursa (job #172181) | Cod sursa (job #2948898) | Cod sursa (job #541754) | Cod sursa (job #2280994)
#include <iostream>
#include <fstream>
using namespace std;
ifstream f("fact.in");
ofstream g("fact.out");
const long long maxx = 100000000;
int check(long long mij, long long n)
{
long long a = 5, s=0;
while(mij / a > 0)
{
s = s + mij / a;
a *= 5;
}
return s;
}
int nr=1;
void cautbinar(long long st, long long dr, long long n)
{
if(st <= dr)
{
long long mij = (st + dr) / 2;
int verf = check(mij, n);
if (verf >= n && (check(mij - 1, n) < n))
{
g << mij;
return;
}
if (verf >= n)
cautbinar(st, mij - 1, n);
else
cautbinar(mij + 1, dr, n);
}
}
int main()
{
unsigned long long p;
f >> p;
if(p == 0)
g << 1;
else
if(p == 1)
g << 5;
else
cautbinar(1, maxx, p);
return 0;
}